nixos/nix-{gc,optimise}: do not start when switching

Co-authored-by: Sizhe Zhao <prc.zhao@outlook.com>
This commit is contained in:
Sandro Jäckel 2025-06-09 16:31:15 +02:00
parent 1755d9399b
commit e9efb4240e
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
2 changed files with 4 additions and 0 deletions

View File

@ -88,6 +88,8 @@ in
script = "exec ${config.nix.package.out}/bin/nix-collect-garbage ${cfg.options}";
serviceConfig.Type = "oneshot";
startAt = lib.optionals cfg.automatic cfg.dates;
# do not start and delay when switching
restartIfChanged = false;
};
systemd.timers.nix-gc = lib.mkIf cfg.automatic {

View File

@ -69,6 +69,8 @@ in
unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise";
startAt = lib.optionals cfg.automatic cfg.dates;
# do not start and delay when switching
restartIfChanged = false;
};
timers.nix-optimise = lib.mkIf cfg.automatic {