Skip to content
matthew-hrePublic

About

Home Manager module for pruning old node_modules folders

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dustpan

Warning

This flake has moved! It now lives on Tangled.

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 = "git+https://tangled.org/matthew-hre.com/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

Stars

7 stars

Watchers

0 watching

Forks

Contributors

Languages