remove old gc roots before running nix gc

This commit is contained in:
xunuwu 2025-05-28 20:14:47 +02:00
parent 1b2b53fbf6
commit 559f9e170b
Signed by: xun
SSH key fingerprint: SHA256:Uot/1WoAjWAeqLOHA5vYy4phhVydsH7jCPmBjaPZfgI

View file

@ -1,7 +1,21 @@
{ {
lib,
pkgs,
...
}: {
nix.gc = { nix.gc = {
automatic = true; automatic = true;
options = "--delete-older-than 14d"; options = "--delete-older-than 14d";
}; };
nix.optimise.automatic = true; nix.optimise.automatic = true;
systemd.services.remove-old-nix-gc-roots = let
beforeDate = "last month";
in {
description = "Remove old nix gc roots";
script = "exec ${lib.getExe pkgs.findutils} /nix/var/nix/gcroots/auto -not -newermt \"${beforeDate}\" -delete";
serviceConfig.Type = "oneshot";
before = ["nix-gc.service"];
requiredBy = ["nix-gc.service"];
};
} }