From 657be047ec594ff6db249f92e900fc4e312ad5d2 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Thu, 1 Oct 2026 18:35:54 +0200 Subject: [PATCH] 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. --- hosts/backwards/modules/boot/default.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hosts/backwards/modules/boot/default.nix b/hosts/backwards/modules/boot/default.nix index 3098e8a..1925b73 100644 --- a/hosts/backwards/modules/boot/default.nix +++ b/hosts/backwards/modules/boot/default.nix @@ -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 = {