Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.11] nixos/snapper: Add peristentTimer option to config #312549

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion nixos/modules/services/misc/snapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ in
'';
};

persistentTimer = mkOption {
default = false;
type = types.bool;
example = true;
description = ''
Set the `persistentTimer` option for the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should it be Persistent? If so, this (and the one in the borgbackup module) can be fixed in a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed with #314099

{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";
Expand Down Expand Up @@ -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 = {
Expand Down
Loading