diff options
author | Matt Kline <mkline@anduril.com> | 2024-04-25 21:26:44 -0700 |
---|---|---|
committer | Matt Kline <mkline@anduril.com> | 2024-04-25 22:26:18 -0700 |
commit | ff0f4540c088913db38d9a5006b4a85e768c9ae5 (patch) | |
tree | a5e3810bc3e06850ce9a97f91ac91c9095220180 /nixos/modules/services/misc/snapper.nix | |
parent | a73feccb2a3ad78e2359b5504a7b8f7c62faa129 (diff) |
snapper: Add persistentTimer option to config
Defaults to false, but allows users to enable it for machines that aren't on persistently (e.g., laptops, home PCs).
Diffstat (limited to 'nixos/modules/services/misc/snapper.nix')
-rw-r--r-- | nixos/modules/services/misc/snapper.nix | 21 |
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 = { |