diff options
author | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2023-05-20 02:32:19 +0200 |
---|---|---|
committer | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2023-05-20 02:32:19 +0200 |
commit | f2ea5c05c14e7c8ea962058f3028c2aca45993cd (patch) | |
tree | b049eae51c7c93a1ecf4ba03141f023e5a032701 /nixos/modules/services/misc/nix-optimise.nix | |
parent | 879c2dd588d42e6c09bec256a09d262c7abdce9d (diff) |
nixos/nix-optimise: persist timer
otherwise the timer might never run on laptops which could be shutdown during the night
Diffstat (limited to 'nixos/modules/services/misc/nix-optimise.nix')
-rw-r--r-- | nixos/modules/services/misc/nix-optimise.nix | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/nixos/modules/services/misc/nix-optimise.nix b/nixos/modules/services/misc/nix-optimise.nix index 58fc1ea4162ae..0398229a13da9 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; + }; }; }; } |