Skip to content

matthew-hre/dustpan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dustpan

A Home Manager module that prunes build and dependency folders (like node_modules/, target/, etc.) older than N days, automatically, on a timer.

Install and Usage

Add the following to your flake:

inputs.dustpan.url = "github:matthew-hre/dustpan";

outputs = { dustpan, ... }: {
    homeManagerModules.dustpan = dustpan.homeManagerModules.dustpan;
};

And use it in your Home Manager configuration:

{inputs, ...}: {
    imports = [
        inputs.dustpan.homeManagerModules.dustpan
    ];

    services.dustpan = {
        enable = true;
        roots = [ "$HOME/dev" "$HOME/Projects" ];
        targets = [ "node_modules" "__pycache__" "target" ".cache" ];
        olderThanDays = 30;
        frequency = "weekly";
    };
}

Options

  • enable: Enable automatic cleanup of old build/dependency folders (default: false).
  • roots: Directories to search for folders to clean (default: ["$HOME/projects" "$HOME/Projects", "$HOME/dev"]).
  • targets: Names of folders to clean up (default: ["node_modules"]).
  • olderThanDays: Remove folders older than this many days (default: 30).
  • frequency: systemd timer OnCalendar value (default: "weekly").

Result

A systemd timer and service is created to periodically run a cleanup. Logs are visible in the journal:

journalctl --user -u dustpan.service

Why?

I usually have a couple GB of node_modules folders lying around in various projects that I no longer work on, and as great as npkill is, I don't run it as much as I should. Inspired by the nix.gc.automatic flag, this module automates the cleanup process, so that old node_modules folders are pruned regularly.

License

MIT © Matthew Hrehirchuk

About

Home Manager module for pruning old node_modules folders

Topics

Resources

License

Stars

Watchers

Forks

Languages