Add automatic garbage collection for home-manager user profiles

Configure nix.gc to automatically clean up old home-manager generations
weekly, which complements the existing system-level gc. Uses
--delete-older-than 10d on Linux to maintain a rollback window, but
overrides to -d on Darwin to work around a launchd bug where multi-part
options aren't properly split into separate arguments.
This commit is contained in:
2025-12-06 13:58:26 -08:00
parent 89994e3fc8
commit b3add6ddf8
2 changed files with 15 additions and 0 deletions

View File

@@ -4,4 +4,8 @@
imports = [ imports = [
../aerospace ../aerospace
]; ];
# Override to use -d instead of --delete-older-than on Darwin due to launchd bug
# https://github.com/nix-community/home-manager/issues/7211
nix.gc.options = "-d";
} }

View File

@@ -24,6 +24,17 @@ in
tree tree
]; ];
# Automatic garbage collection for user profile (home-manager generations).
# This complements system-level gc which only cleans system generations.
# - Linux: Uses --delete-older-than to keep 10-day rollback window
# - Darwin: Overridden to use -d in base-darwin role to avoid launchd bug
# (https://github.com/nix-community/home-manager/issues/7211)
nix.gc = {
automatic = true;
randomizedDelaySec = mkIf pkgs.stdenv.isLinux "14m";
options = "--delete-older-than 10d";
};
# Essential programs everyone needs # Essential programs everyone needs
programs.bash = { programs.bash = {
enable = true; enable = true;