From e9efb4240e3ca7b56b2ebeded8980128e192fe1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 9 Jun 2025 16:31:15 +0200 Subject: [PATCH] nixos/nix-{gc,optimise}: do not start when switching Co-authored-by: Sizhe Zhao --- nixos/modules/services/misc/nix-gc.nix | 2 ++ nixos/modules/services/misc/nix-optimise.nix | 2 ++ 2 files changed, 4 insertions(+) diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix index 034b044fbafe..d2a7f0bf433e 100644 --- a/nixos/modules/services/misc/nix-gc.nix +++ b/nixos/modules/services/misc/nix-gc.nix @@ -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 { diff --git a/nixos/modules/services/misc/nix-optimise.nix b/nixos/modules/services/misc/nix-optimise.nix index 3581b95ce18a..ad12e9a83d2f 100644 --- a/nixos/modules/services/misc/nix-optimise.nix +++ b/nixos/modules/services/misc/nix-optimise.nix @@ -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 {