Merge pull request #306909 from mrkline/snapper-timer

nixos/snapper: Add persistent option to config
This commit is contained in:
tomberek 2024-05-17 10:01:04 -05:00 committed by GitHub
commit 2c55e033f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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