nixos/auto-upgrade: add system.autoUpgrade.fixedRandomDelay

From systemd 247, timers can be configured to randomize their delay
once and to apply the same random delay for all future executions.
This allows users to have less jitter between auto-upgrade executions
while still avoiding multiple timers firing simultaneously on a
machine or multiple machines all performing their upgrades
simultaneously.

The default option value (false) is backwards compatible.

All supported versions of NixOS (in fact, back to and including 21.05)
use systemd 247 or later.
This commit is contained in:
Simon Hollingshead 2024-01-13 03:18:16 +00:00
parent 28330aa204
commit d077cd8691

View file

@ -109,6 +109,17 @@ in {
'';
};
fixedRandomDelay = mkOption {
default = false;
type = types.bool;
example = true;
description = lib.mdDoc ''
Make the randomized delay consistent between runs.
This reduces the jitter between automatic upgrades.
See {option}`randomizedDelaySec` for configuring the randomized delay.
'';
};
rebootWindow = mkOption {
description = lib.mdDoc ''
Define a lower and upper time value (in HH:MM format) which
@ -253,6 +264,7 @@ in {
systemd.timers.nixos-upgrade = {
timerConfig = {
RandomizedDelaySec = cfg.randomizedDelaySec;
FixedRandomDelay = cfg.fixedRandomDelay;
Persistent = cfg.persistent;
};
};