diff --git a/modules/nix-tools/rebuild.nix b/modules/nix-tools/rebuild.nix index 491f902..d9c8723 100644 --- a/modules/nix-tools/rebuild.nix +++ b/modules/nix-tools/rebuild.nix @@ -87,6 +87,19 @@ ${echoCmd} "Testing the evaulation of the nixos config for $HOSTNAME" ${lib.getExe nix} eval ${flakeDir}#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath '') + + (writeShellScriptBin "cleanup" '' + set -e + DAYS=$1 + if [ -z "$DAYS" ]; then + ${echoCmd} "usage: cleanup " + exit 1 + fi + ${lib.getExe home-manager} expire-generations "-$DAYS days" + ${lib.getExe nix} profile wipe-history --older-than "''${DAYS}d" + ${lib.getExe nix} store gc + ${lib.getExe nix} store optimise + '') ]; }; };