about summary refs log tree commit diff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorSimon Hollingshead <me@simonhollingshead.com>2024-01-13 03:18:16 +0000
committerSimon Hollingshead <me@simonhollingshead.com>2024-01-13 03:40:44 +0000
commitd077cd8691af1957438a908e61ae271371c4d334 (patch)
tree8243473290a38657bda117d013c8a50207d8efcd /nixos/modules/tasks
parent28330aa2040cb412315ea884f2864b17cade222e (diff)
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.
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/auto-upgrade.nix12
1 files changed, 12 insertions, 0 deletions
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;
       };
     };