summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--custom/borgbackup.nix16
1 files changed, 8 insertions, 8 deletions
diff --git a/custom/borgbackup.nix b/custom/borgbackup.nix
index e3e61c82..7da35b05 100644
--- a/custom/borgbackup.nix
+++ b/custom/borgbackup.nix
@@ -59,7 +59,7 @@ in {
59 config = mkIf (any (t: t.paths != []) (attrValues cfg.targets)) { 59 config = mkIf (any (t: t.paths != []) (attrValues cfg.targets)) {
60 services.btrfs-snapshots.enable = mkIf (cfg.snapshots == "btrfs") true; 60 services.btrfs-snapshots.enable = mkIf (cfg.snapshots == "btrfs") true;
61 61
62 systemd.timers = listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}-${path}" { 62 systemd.timers = (listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}-${path}" {
63 wantedBy = [ "timers.target" ]; 63 wantedBy = [ "timers.target" ];
64 64
65 timerConfig = { 65 timerConfig = {
@@ -67,7 +67,7 @@ in {
67 OnBootSec = tCfg.interval; 67 OnBootSec = tCfg.interval;
68 OnUnitInactiveSec = tCfg.interval; 68 OnUnitInactiveSec = tCfg.interval;
69 }; 69 };
70 }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets))) // mapAttrs (target: tCfg: nameValuePair "borgbackup-prune-${target}" { 70 }) (flatten (mapAttrsToList (target: tCfg: map (path: { inherit target path tCfg; }) tCfg.paths) cfg.targets)))) // (mapAttrs (target: tCfg: nameValuePair "borgbackup-prune-${target}" {
71 wantedBy = [ "timers.target" ]; 71 wantedBy = [ "timers.target" ];
72 72
73 timerConfig = { 73 timerConfig = {
@@ -75,9 +75,9 @@ in {
75 OnBootSec = tCfg.interval; 75 OnBootSec = tCfg.interval;
76 OnUnitInactiveSec = tCfg.interval; 76 OnUnitInactiveSec = tCfg.interval;
77 }; 77 };
78 }) cfg.targets; 78 }) cfg.targets);
79 79
80 systemd.services = mapAttrs (target: tCfg: nameValuePair "borgbackup-${target}@" (let 80 systemd.services = (mapAttrs (target: tCfg: nameValuePair "borgbackup-${target}@" (let
81 deps = flatten [ 81 deps = flatten [
82 (optional (cfg.snapshots == "btrfs") "btrfs-snapshot@%p.service") 82 (optional (cfg.snapshots == "btrfs") "btrfs-snapshot@%p.service")
83 (optional tCfg.network "network-online.target") 83 (optional tCfg.network "network-online.target")
@@ -117,20 +117,20 @@ in {
117 IOSchedulingPriority = 7; 117 IOSchedulingPriority = 7;
118 SuccessExitStatus = [1 2]; 118 SuccessExitStatus = [1 2];
119 }; 119 };
120 })) cfg.targets // mapAttrs (target: tCfg: nameValuePair "borgbackup-prune-${target}" { 120 })) cfg.targets) // (mapAttrs (target: tCfg: nameValuePair "borgbackup-prune-${target}" {
121 bindsTo = "network-online.target"; 121 bindsTo = "network-online.target";
122 after = "network-online.target"; 122 after = "network-online.target";
123 123
124 script = concatStringsSep "\n" (mapAttrsToList ('' 124 script = concatStringsSep "\n" (mapAttrsToList (path: args: ''
125 borg prune \ 125 borg prune \
126 --prefix "${cfg.prefix}${path}" \ 126 --prefix "${cfg.prefix}${path}" \
127 ${concatStringsSep " " tCfg.prune."${path}"} \ 127 ${concatStringsSep " " args} \
128 ${tCfg.repo} 128 ${tCfg.repo}
129 '') tCfg.prune); 129 '') tCfg.prune);
130 130
131 serviceConfig = { 131 serviceConfig = {
132 Type = "oneshot"; 132 Type = "oneshot";
133 }; 133 };
134 }) cfg.targets; 134 }) cfg.targets);
135 }; 135 };
136} 136}