diff --git a/nixos/modules/services/misc/nix-optimise.nix b/nixos/modules/services/misc/nix-optimise.nix index 58fc1ea4162a..0398229a13da 100644 --- a/nixos/modules/services/misc/nix-optimise.nix +++ b/nixos/modules/services/misc/nix-optimise.nix @@ -33,12 +33,19 @@ in } ]; - systemd.services.nix-optimise = lib.mkIf config.nix.enable { - description = "Nix Store Optimiser"; - # No point this if the nix daemon (and thus the nix store) is outside - unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket"; - serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise"; - startAt = lib.optionals cfg.automatic cfg.dates; + systemd = lib.mkIf config.nix.enable { + services.nix-optimise = { + description = "Nix Store Optimiser"; + # No point this if the nix daemon (and thus the nix store) is outside + unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket"; + serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise"; + startAt = lib.optionals cfg.automatic cfg.dates; + }; + + timers.nix-optimise.timerConfig = { + Persistent = true; + RandomizedDelaySec = 1800; + }; }; }; }