summary refs log tree commit diff
diff options
context:
space:
mode:
authorMilan Svoboda <milan.svoboda@centrum.cz>2020-12-30 12:00:25 +0100
committerlassulus <lassulus@lassul.us>2022-04-16 19:27:21 +0200
commita5fb565bf50b4efb8409f58a5c7ba47418be64ad (patch)
treeec27f1f28922421490471a8ece7480b678e4644b
parentac83e58d622dddb4a64c526fe29f9c70c9f5eb62 (diff)
downloadnixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.tar
nixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.tar.gz
nixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.tar.bz2
nixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.tar.lz
nixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.tar.xz
nixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.tar.zst
nixpkgs-a5fb565bf50b4efb8409f58a5c7ba47418be64ad.zip
nixos/auto-upgrade: add persistent option
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2205.section.xml8
-rw-r--r--nixos/doc/manual/release-notes/rl-2205.section.md4
-rw-r--r--nixos/modules/tasks/auto-upgrade.nix39
3 files changed, 44 insertions, 7 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
index 96dbfd59c83..85c97ead8c3 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
@@ -1508,6 +1508,14 @@
       </listitem>
       <listitem>
         <para>
+          The auto-upgrade service now accepts persistent (default:
+          true) parameter. By default auto-upgrade will now run
+          immediately if it would have been triggered at least once
+          during the time when the timer was inactive.
+        </para>
+      </listitem>
+      <listitem>
+        <para>
           If you are using Wayland you can choose to use the Ozone
           Wayland support in Chrome and several Electron apps by setting
           the environment variable <literal>NIXOS_OZONE_WL=1</literal>
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md
index a1b0212fafc..9d240c99591 100644
--- a/nixos/doc/manual/release-notes/rl-2205.section.md
+++ b/nixos/doc/manual/release-notes/rl-2205.section.md
@@ -520,6 +520,10 @@ In addition to numerous new and upgraded packages, this release has the followin
   - Support for older versions of hadoop have been added to the module
   - Overriding and extending site XML files has been made easier
 
+- The auto-upgrade service now accepts persistent (default: true) parameter.
+  By default auto-upgrade will now run immediately if it would have been triggered at least
+  once during the time when the timer was inactive.
+
 - If you are using Wayland you can choose to use the Ozone Wayland support
   in Chrome and several Electron apps by setting the environment variable
   `NIXOS_OZONE_WL=1` (for example via
diff --git a/nixos/modules/tasks/auto-upgrade.nix b/nixos/modules/tasks/auto-upgrade.nix
index a5755d08d7d..d00dc761d6e 100644
--- a/nixos/modules/tasks/auto-upgrade.nix
+++ b/nixos/modules/tasks/auto-upgrade.nix
@@ -63,13 +63,16 @@ in {
       };
 
       dates = mkOption {
-        default = "04:40";
         type = types.str;
+        default = "04:40";
+        example = "daily";
         description = ''
-          Specification (in the format described by
+          How often or when upgrade occurs. For most desktop and server systems
+          a sufficient upgrade frequency is once a day.
+
+          The format is described in
           <citerefentry><refentrytitle>systemd.time</refentrytitle>
-          <manvolnum>7</manvolnum></citerefentry>) of the time at
-          which the update will occur.
+          <manvolnum>7</manvolnum></citerefentry>.
         '';
       };
 
@@ -123,6 +126,22 @@ in {
         });
       };
 
+      persistent = mkOption {
+        default = true;
+        type = types.bool;
+        example = false;
+        description = ''
+          Takes a boolean argument. If true, the time when the service
+          unit was last triggered is stored on disk. When the timer is
+          activated, the service unit is triggered immediately if it
+          would have been triggered at least once during the time when
+          the timer was inactive. Such triggering is nonetheless
+          subject to the delay imposed by RandomizedDelaySec=. This is
+          useful to catch up on missed runs of the service when the
+          system was powered down.
+        '';
+      };
+
     };
 
   };
@@ -217,11 +236,17 @@ in {
       '';
 
       startAt = cfg.dates;
-    };
 
-    systemd.timers.nixos-upgrade.timerConfig.RandomizedDelaySec =
-      cfg.randomizedDelaySec;
+      after = [ "network-online.target" ];
+      wants = [ "network-online.target" ];
+    };
 
+    systemd.timers.nixos-upgrade = {
+      timerConfig = {
+        RandomizedDelaySec = cfg.randomizedDelaySec;
+        Persistent = cfg.persistent;
+      };
+    };
   };
 
 }