From 2791cedcba6728c42e4793c8f6c32e4b37ec008e Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sat, 30 Dec 2023 09:24:50 +1100 Subject: [PATCH] zpool: only `unmount` when root dataset is mounted Fixes #486 --- lib/types/zpool.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/types/zpool.nix b/lib/types/zpool.nix index 7654ca5..e48dc19 100644 --- a/lib/types/zpool.nix +++ b/lib/types/zpool.nix @@ -67,9 +67,9 @@ ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \ ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \ "''${zfs_devices[@]}" - ${lib.optionalString ((config.rootFsOptions.mountpoint or "") != "none") '' + if [[ $(zfs get -H mounted ${config.name} | cut -f3) == "yes" ]]; then zfs unmount ${config.name} - ''} + fi ${lib.concatMapStrings (dataset: dataset._create) (lib.attrValues config.datasets)} ''; };