summaryrefslogtreecommitdiff
path: root/custom/lvm-snapshots.nix
diff options
context:
space:
mode:
Diffstat (limited to 'custom/lvm-snapshots.nix')
-rw-r--r--custom/lvm-snapshots.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/custom/lvm-snapshots.nix b/custom/lvm-snapshots.nix
index 86b3061a..c78de3a5 100644
--- a/custom/lvm-snapshots.nix
+++ b/custom/lvm-snapshots.nix
@@ -9,6 +9,8 @@ let
9 snapshotMount = name: "${cfg.mountPoint}/${if isNull cfg.snapshots."${name}".mountName then name else cfg.snapshots."${name}".mountName}"; 9 snapshotMount = name: "${cfg.mountPoint}/${if isNull cfg.snapshots."${name}".mountName then name else cfg.snapshots."${name}".mountName}";
10 snapshotName = name: "${name}-snapshot"; 10 snapshotName = name: "${name}-snapshot";
11 11
12 instance = scfg: escapeSystemdPath (scfg.VG + "/" + scfg.LV);
13
12 snapshotConfig = { 14 snapshotConfig = {
13 options = { 15 options = {
14 LV = mkOption { 16 LV = mkOption {
@@ -65,7 +67,7 @@ in {
65 mkdir -p ${snapshotMount name} 67 mkdir -p ${snapshotMount name}
66 '') cfg.snapshots; 68 '') cfg.snapshots;
67 69
68 systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + scfg.VG + "-" + snapshotName name) { 70 systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + instance scfg) {
69 enable = true; 71 enable = true;
70 72
71 description = "LVM-snapshot of ${scfg.VG}/${scfg.LV}"; 73 description = "LVM-snapshot of ${scfg.VG}/${scfg.LV}";
@@ -109,8 +111,8 @@ in {
109 StopWhenUnneeded = !scfg.persist; 111 StopWhenUnneeded = !scfg.persist;
110 }; 112 };
111 113
112 bindsTo = [ ("lvm-snapshot@" + scfg.VG + "-" + snapshotName name + ".service") ]; 114 bindsTo = [ ("lvm-snapshot@" + instance scfg + ".service") ];
113 after = [ ("lvm-snapshot@" + scfg.VG + "-" + snapshotName name + ".service") ]; 115 after = [ ("lvm-snapshot@" + instance scfg + ".service") ];
114 116
115 options = concatStringsSep "," ([ "noauto" ] ++ optional scfg.readOnly "ro"); 117 options = concatStringsSep "," ([ "noauto" ] ++ optional scfg.readOnly "ro");
116 118