From 215ab1596bc5adfc16789844e2e9d3b27cc698c0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 9 Apr 2018 14:57:30 +0200 Subject: cleanup --- custom/borgbackup.nix | 8 ++++++-- custom/btrfs-snapshots.nix | 4 +--- custom/lvm-snapshots.nix | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/custom/borgbackup.nix b/custom/borgbackup.nix index fe380695..ab826757 100644 --- a/custom/borgbackup.nix +++ b/custom/borgbackup.nix @@ -21,6 +21,10 @@ let systemdPath = path: if cfg.snapshots == "lvm" then escapeSystemdPath "${path.VG}/${path.LV}" else escapeSystemdPath path; + withPrefix = path: config.services.btrfs-snapshots.mountPrefix + path; + + mountPoint = if cfg.snapshots == "lvm" then config.services.lvm-snapshots.mountPoint else config.services.btrfs-snapshots.mountPoint; + targetOptions = { options = { repo = mkOption { @@ -88,7 +92,7 @@ in { services.lvm-snapshots.snapshots = mkIf (cfg.snapshots == "lvm") (listToAttrs (map (path: nameValuePair (escapeSystemdPath path.LV) { inherit (path) LV VG; - mountName = "snapshot-${systemdPath path}"; + mountName = withPrefix (systemdPath path); }) (unique (flatten (mapAttrsToList (target: tCfg: tCfg.paths) cfg.targets))))); systemd.timers = (listToAttrs (map ({ target, path, tCfg }: nameValuePair "borgbackup-${target}@${systemdPath path}" { @@ -143,7 +147,7 @@ in { serviceConfig = { Type = "oneshot"; - WorkingDirectory = if (cfg.snapshots == null) then "%p" else "/mnt/snapshot-%i"; + WorkingDirectory = if (cfg.snapshots == null) then "%p" else "${mountPoint}/${withPrefix "%i"}"; Nice = 15; IOSchedulingClass = 2; IOSchedulingPriority = 7; diff --git a/custom/btrfs-snapshots.nix b/custom/btrfs-snapshots.nix index 9dc3f1f8..39e0bf0c 100644 --- a/custom/btrfs-snapshots.nix +++ b/custom/btrfs-snapshots.nix @@ -13,13 +13,11 @@ in { enable = mkEnableOption "a systemd unit for btrfs snapshots"; mountPoint = mkOption { - readOnly = true; type = types.path; default = "/mnt"; }; mountPrefix = mkOption { - readOnly = true; type = types.str; default = "snapshot-"; }; @@ -41,7 +39,7 @@ in { config = mkIf cfg.enable { system.activationScripts."btrfs-snapshots" = '' - mkdir -p ${mountPoint} + mkdir -p ${cfg.mountPoint} ''; systemd.services."btrfs-snapshot@" = { diff --git a/custom/lvm-snapshots.nix b/custom/lvm-snapshots.nix index c7f6416e..af8b61bb 100644 --- a/custom/lvm-snapshots.nix +++ b/custom/lvm-snapshots.nix @@ -50,7 +50,6 @@ in { mountPoint = mkOption { type = types.path; - readOnly = true; default = "/mnt"; }; }; -- cgit v1.2.3