From b6a85631f322f526328a9a0069e4b1e9239c52d0 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Mon, 30 Mar 2026 18:59:28 -0500 Subject: [PATCH] cleanup script --- modules/nix-tools/rebuild.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 + '') ]; }; };