From d077cd8691af1957438a908e61ae271371c4d334 Mon Sep 17 00:00:00 2001 From: Simon Hollingshead Date: Sat, 13 Jan 2024 03:18:16 +0000 Subject: 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. --- nixos/modules/tasks/auto-upgrade.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'nixos') diff --git a/nixos/modules/tasks/auto-upgrade.nix b/nixos/modules/tasks/auto-upgrade.nix index 29e3e313336f5..22311871274b9 100644 --- a/nixos/modules/tasks/auto-upgrade.nix +++ b/nixos/modules/tasks/auto-upgrade.nix @@ -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; }; }; -- cgit 1.4.1