about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authortomberek <tomberek@users.noreply.github.com>2024-05-17 10:01:04 -0500
committerGitHub <noreply@github.com>2024-05-17 10:01:04 -0500
commit2c55e033f271eae674d504d4887b6f45ab17c35b (patch)
tree36aec41c718955c86a0168de54df4dff0693d318 /nixos
parenteb8a9ec2073ebf33d91e1fe76a55ea2ae77e9766 (diff)
parentff0f4540c088913db38d9a5006b4a85e768c9ae5 (diff)
Merge pull request #306909 from mrkline/snapper-timer
nixos/snapper: Add persistent option to config
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/snapper.nix21
1 files changed, 20 insertions, 1 deletions
diff --git a/nixos/modules/services/misc/snapper.nix b/nixos/modules/services/misc/snapper.nix
index 3a3ed1b5c0f56..33207ac2b5bd5 100644
--- a/nixos/modules/services/misc/snapper.nix
+++ b/nixos/modules/services/misc/snapper.nix
@@ -103,6 +103,18 @@ in
       '';
     };
 
+    persistentTimer = mkOption {
+      default = false;
+      type = types.bool;
+      example = true;
+      description = ''
+        Set the `persistentTimer` option for the
+        {manpage}`systemd.timer(5)`
+        which triggers the snapshot immediately if the last trigger
+        was missed (e.g. if the system was powered down).
+      '';
+    };
+
     cleanupInterval = mkOption {
       type = types.str;
       default = "1d";
@@ -198,7 +210,14 @@ in
       inherit documentation;
       requires = [ "local-fs.target" ];
       serviceConfig.ExecStart = "${pkgs.snapper}/lib/snapper/systemd-helper --timeline";
-      startAt = cfg.snapshotInterval;
+    };
+
+    systemd.timers.snapper-timeline = {
+      wantedBy = [ "timers.target" ];
+      timerConfig = {
+        Persistent = cfg.persistentTimer;
+        OnCalendar = cfg.snapshotInterval;
+      };
     };
 
     systemd.services.snapper-cleanup = {