From 7f3b98f72b5ca73c46db3993bcebb2fa617d163f Mon Sep 17 00:00:00 2001 From: rogarb Date: Sun, 9 Jul 2023 21:18:11 +0200 Subject: [PATCH] fix(btrfs): subvolume mount behaviour Since subvolumes appear automatically when their parent is mounted, no action is required until the user wants them to be mounted somewhere else. This allows access to the volume manager capabilities of BTRFS. --- lib/types/btrfs.nix | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/types/btrfs.nix b/lib/types/btrfs.nix index 4439ff8..3c9aa8f 100644 --- a/lib/types/btrfs.nix +++ b/lib/types/btrfs.nix @@ -91,16 +91,10 @@ let subvolMounts = lib.concatMapAttrs (_: subvol: - let - mountpoint = - if (subvol.mountpoint != null) then subvol.mountpoint - else if (config.mountpoint == null) then subvol.name - else null; - in - lib.optionalAttrs (mountpoint != null) { - ${mountpoint} = '' - if ! findmnt ${config.device} "${rootMountPoint}${mountpoint}" > /dev/null 2>&1; then - mount ${config.device} "${rootMountPoint}${mountpoint}" \ + lib.optionalAttrs (subvol.mountpoint != null) { + ${subvol.mountpoint} = '' + if ! findmnt ${config.device} "${rootMountPoint}${subvol.mountpoint}" > /dev/null 2>&1; then + mount ${config.device} "${rootMountPoint}${subvol.mountpoint}" \ ${lib.concatMapStringsSep " " (opt: "-o ${opt}") (subvol.mountOptions ++ [ "subvol=${subvol.name}" ])} \ -o X-mount.mkdir fi