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).
This commit is contained in:
Matt Kline 2024-04-25 21:26:44 -07:00
parent a73feccb2a
commit ff0f4540c0

View File

@ -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 = {