nixos/nix-optimise: persist timer

otherwise the timer might never run on laptops which could be shutdown
during the night
This commit is contained in:
Sandro Jäckel
2023-05-20 02:32:19 +02:00
parent 879c2dd588
commit f2ea5c05c1

View File

@@ -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;
};
};
};
}