From 5d6a7a5406efdac450bc869f26a94739e13936d7 Mon Sep 17 00:00:00 2001 From: Jul Lang Date: Sat, 10 Jan 2026 13:35:16 +0100 Subject: [PATCH 1/4] bcachefs: use colon-separated list of devices for unlock & mount Fixes unreliable uuid expansion --- lib/types/bcachefs_filesystem.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/types/bcachefs_filesystem.nix b/lib/types/bcachefs_filesystem.nix index 8a453672..f522024d 100644 --- a/lib/types/bcachefs_filesystem.nix +++ b/lib/types/bcachefs_filesystem.nix @@ -7,6 +7,12 @@ rootMountPoint, ... }: +let + # colon separated list of devices, as UUID expansion is unreliable + colonSeparatedDevices = '' + $(cat "${disko_devices_dir}/bcachefs-${config.name}" | paste -sd ":" -) + ''; +in { options = { name = lib.mkOption { @@ -197,7 +203,7 @@ mount \ -t bcachefs \ -o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \ - "/dev/disk/by-uuid/${config.uuid}" \ + "${colonSeparatedDevices}" \ "$MNTPOINT"; trap 'umount "$MNTPOINT"; rm -rf "$MNTPOINT"; rm -rf "$TEMPDIR";' EXIT; SUBVOL_ABS_PATH="$MNTPOINT/${subvolume.name}"; @@ -244,7 +250,7 @@ ) ) }" \ - "/dev/disk/by-uuid/${config.uuid}" \ + "${colonSeparatedDevices}" \ "${rootMountPoint}${subvolume.mountpoint}"; fi; ''; @@ -266,7 +272,7 @@ mount \ -t bcachefs \ -o "${lib.concatStringsSep "," (lib.unique ([ "X-mount.mkdir" ] ++ config.mountOptions))}" \ - "/dev/disk/by-uuid/${config.uuid}" \ + "${colonSeparatedDevices}" \ "${rootMountPoint}${config.mountpoint}"; fi; ''; From cd7a2bf5a9485e07ebc31a0a173d5a717a2e579e Mon Sep 17 00:00:00 2001 From: Jul Lang Date: Sat, 10 Jan 2026 13:52:30 +0100 Subject: [PATCH 2/4] fix accidental escape --- lib/types/bcachefs_filesystem.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/bcachefs_filesystem.nix b/lib/types/bcachefs_filesystem.nix index f522024d..5d44cca9 100644 --- a/lib/types/bcachefs_filesystem.nix +++ b/lib/types/bcachefs_filesystem.nix @@ -10,7 +10,7 @@ let # colon separated list of devices, as UUID expansion is unreliable colonSeparatedDevices = '' - $(cat "${disko_devices_dir}/bcachefs-${config.name}" | paste -sd ":" -) + $(cat "$disko_devices_dir/bcachefs-${config.name}" | paste -sd ":" -) ''; in { From 8214feed8687c1638cdc9e4277d4b1221440e25f Mon Sep 17 00:00:00 2001 From: Jul Lang Date: Sat, 10 Jan 2026 14:01:23 +0100 Subject: [PATCH 3/4] bcachefs: use last field of bcachefs-config-name --- lib/types/bcachefs_filesystem.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/bcachefs_filesystem.nix b/lib/types/bcachefs_filesystem.nix index 5d44cca9..258604de 100644 --- a/lib/types/bcachefs_filesystem.nix +++ b/lib/types/bcachefs_filesystem.nix @@ -10,7 +10,7 @@ let # colon separated list of devices, as UUID expansion is unreliable colonSeparatedDevices = '' - $(cat "$disko_devices_dir/bcachefs-${config.name}" | paste -sd ":" -) + $(awk '{print $NF}' "$disko_devices_dir/bcachefs-${config.name}" | paste -sd ":" -) ''; in { From d1870fbb6a3c73bc84bf73b17b512166da9ab926 Mon Sep 17 00:00:00 2001 From: Jul Lang Date: Sat, 10 Jan 2026 14:17:33 +0100 Subject: [PATCH 4/4] bcachefs: write devices without args to separate file --- lib/types/bcachefs.nix | 2 ++ lib/types/bcachefs_filesystem.nix | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/types/bcachefs.nix b/lib/types/bcachefs.nix index a1e00a15..bce84367 100644 --- a/lib/types/bcachefs.nix +++ b/lib/types/bcachefs.nix @@ -64,6 +64,8 @@ # The current file should not run the `bcachefs format` command. Instead, the`bcachefs format` command will be ran # in the `_create` attribute in bcachefs_filesystem.nix, once it has collected and generated the arguments specifying the devices that should be part of the filesystem. default = '' + # Write devices to temporary directory for bcachefs_filesystem. + printf '%s\n' '${config.device}' >> "$disko_devices_dir/bcachefs-${lib.escapeShellArg config.filesystem}-devices"; # Write device arguments to temporary directory for bcachefs_filesystem. { printf '%s\n' '--label=${config.label}'; diff --git a/lib/types/bcachefs_filesystem.nix b/lib/types/bcachefs_filesystem.nix index 258604de..bbfefd41 100644 --- a/lib/types/bcachefs_filesystem.nix +++ b/lib/types/bcachefs_filesystem.nix @@ -9,9 +9,7 @@ }: let # colon separated list of devices, as UUID expansion is unreliable - colonSeparatedDevices = '' - $(awk '{print $NF}' "$disko_devices_dir/bcachefs-${config.name}" | paste -sd ":" -) - ''; + colonSeparatedDevices = ''$(paste -sd ":" "$disko_devices_dir/bcachefs-${config.name}-devices")''; in { options = {