diff options
author | lassulus <lassulus@lassul.us> | 2017-07-22 23:01:18 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2017-07-22 23:55:00 +0200 |
commit | 54a594dc474255b24bbff80bb6be28e6a1a523d4 (patch) | |
tree | fb22a3baee6bf04f30813532c026ce0186a5649f /krebs/3modules/backup.nix | |
parent | dc183f8b23242d16bae764f927cf3b22fce5260c (diff) |
krebs backup: extend api with timerConfig
Diffstat (limited to 'krebs/3modules/backup.nix')
-rw-r--r-- | krebs/3modules/backup.nix | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/krebs/3modules/backup.nix b/krebs/3modules/backup.nix index bfb0ab591..6f015d66b 100644 --- a/krebs/3modules/backup.nix +++ b/krebs/3modules/backup.nix @@ -54,6 +54,12 @@ let }; }); }; + timerConfig = mkOption { + type = with types; attrsOf str; + default = optionalAttrs (config.startAt != null) { + OnCalendar = config.startAt; + }; + }; }; })); }; @@ -82,11 +88,19 @@ let SyslogIdentifier = ExecStart.name; Type = "oneshot"; }; - startAt = mkIf (plan.startAt != null) plan.startAt; }) (filter (plan: build-host-is "pull" "dst" plan || build-host-is "push" "src" plan) enabled-plans)); + systemd.timers = + listToAttrs (map (plan: nameValuePair "backup.${plan.name}" { + wantedBy = [ "timers.target" ]; + timerConfig = plan.timerConfig; + }) (filter (plan: plan.timerConfig != {} && ( + build-host-is "pull" "dst" plan || + build-host-is "push" "src" plan)) + enabled-plans)); + users.groups.backup.gid = genid "backup"; users.users.root.openssh.authorizedKeys.keys = map (plan: getAttr plan.method { |