backwards: Replace nix-gc-env with nh clean
`nix.gc` run as root cannot prune generations under `~/.local/state/nix/profiles` (NixOS/nix#8508), and `nix-gc-env` only looks in `/nix/var/nix/profiles`. Home-manager generations therefore accumulated since August 2024 and filled the disk. `nh clean all` enumerates users and walks their per-user profiles too. It replaces `nix.gc.automatic`, which cannot be enabled alongside it.
This commit is contained in:
1 parent
062321ee7f
commit
657be047ec
1 file changed
+10
-8
@@ -1,5 +1,4 @@
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
@@ -8,8 +7,6 @@ let
|
||||
configurationLimit = config.mod.gc.configurationLimit;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.nix-gc-env.nixosModules.default ];
|
||||
|
||||
options = {
|
||||
mod.gc = {
|
||||
configurationLimit = lib.mkOption {
|
||||
@@ -21,12 +18,17 @@ in
|
||||
};
|
||||
|
||||
config = {
|
||||
nix.gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
# `nix.gc` cannot prune generations under `~/.local/state/nix/profiles`
|
||||
# when run as root (NixOS/nix#8508), so home-manager generations piled up.
|
||||
# `nh clean` walks those per-user profiles too.
|
||||
programs.nh = {
|
||||
enable = true;
|
||||
|
||||
# `delete_generations` added by nix-gc-env
|
||||
delete_generations = "+${builtins.toString configurationLimit}";
|
||||
clean = {
|
||||
enable = true;
|
||||
dates = "weekly";
|
||||
extraArgs = "--keep ${builtins.toString configurationLimit}";
|
||||
};
|
||||
};
|
||||
|
||||
boot = {
|
||||
|
||||
Reference in new issue
Block a user