From ffec7ef64c332281472d406a8b1b3995df1e5a25 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 14 Apr 2018 17:48:12 +0200 Subject: =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom/borgbackup.nix | 10 +++++----- custom/lvm-snapshots.nix | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'custom') diff --git a/custom/borgbackup.nix b/custom/borgbackup.nix index 9c696393..865cda3b 100644 --- a/custom/borgbackup.nix +++ b/custom/borgbackup.nix @@ -19,7 +19,7 @@ let pathType = if cfg.snapshots == "lvm" then types.submodule lvmPath else types.path; - systemdPath = path: if cfg.snapshots == "lvm" then escapeSystemdPath "${path.VG}/${path.LV}" else escapeSystemdPath path; + systemdPath = path: escapeSystemdPath (if cfg.snapshots == "lvm" then "${path.VG}-${path.LV}" else path); withPrefix = path: config.services.btrfs-snapshots.mountPrefix + path; @@ -90,9 +90,9 @@ in { services.btrfs-snapshots.enable = mkIf (cfg.snapshots == "btrfs") true; - services.lvm-snapshots.snapshots = mkIf (cfg.snapshots == "lvm") (listToAttrs (map (path: nameValuePair (escapeSystemdPath (path.VG + "/" + path.LV)) { + services.lvm-snapshots.snapshots = mkIf (cfg.snapshots == "lvm") (listToAttrs (map (path: nameValuePair (path.VG + "-" + path.LV) { inherit (path) LV VG; - mountName = withPrefix (systemdPath path); + mountName = withPrefix (VG + "-" + LV); }) (unique (flatten (mapAttrsToList (target: tCfg: tCfg.paths) cfg.targets))))); systemd.timers = (listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}@${systemdPath path}" { @@ -146,12 +146,12 @@ in { unitConfig = { AssertPathIsDirectory = mkIf (tCfg.lock != null) "/var/lock"; DefaultDependencies = false; - RequiresMountsFor = mkIf (cfg.snapshots == "lvm") [ "${mountPoint}/${withPrefix "%i"}" ]; + RequiresMountsFor = mkIf (cfg.snapshots == "lvm") [ "${mountPoint}/${withPrefix "%I"}" ]; }; serviceConfig = { Type = "oneshot"; - WorkingDirectory = if (cfg.snapshots == null) then "%p" else "${mountPoint}/${withPrefix "%i"}"; + WorkingDirectory = if (cfg.snapshots == null) then "%I" else (if (cfg.snapshots == "lvm") then "${mountPoint}/${withPrefix "%I"}" else "${mountPoint}/${withPrefix "%i"}"); Nice = 15; IOSchedulingClass = 2; IOSchedulingPriority = 7; diff --git a/custom/lvm-snapshots.nix b/custom/lvm-snapshots.nix index c78de3a5..5e4557f3 100644 --- a/custom/lvm-snapshots.nix +++ b/custom/lvm-snapshots.nix @@ -9,8 +9,6 @@ let snapshotMount = name: "${cfg.mountPoint}/${if isNull cfg.snapshots."${name}".mountName then name else cfg.snapshots."${name}".mountName}"; snapshotName = name: "${name}-snapshot"; - instance = scfg: escapeSystemdPath (scfg.VG + "/" + scfg.LV); - snapshotConfig = { options = { LV = mkOption { @@ -67,7 +65,7 @@ in { mkdir -p ${snapshotMount name} '') cfg.snapshots; - systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + instance scfg) { + systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + escapeSystemdPath name) { enable = true; description = "LVM-snapshot of ${scfg.VG}/${scfg.LV}"; @@ -111,8 +109,8 @@ in { StopWhenUnneeded = !scfg.persist; }; - bindsTo = [ ("lvm-snapshot@" + instance scfg + ".service") ]; - after = [ ("lvm-snapshot@" + instance scfg + ".service") ]; + bindsTo = [ ("lvm-snapshot@" + escapeSystemdPath name + ".service") ]; + after = [ ("lvm-snapshot@" + escapeSystemdPath name + ".service") ]; options = concatStringsSep "," ([ "noauto" ] ++ optional scfg.readOnly "ro"); -- cgit v1.2.3