Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion example/bcachefs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
content = {
type = "gpt";
partitions = {
vdd1 = {
vde1 = {
size = "100%";
content = {
type = "bcachefs";
Expand All @@ -93,6 +93,16 @@
};
};
};

vdf = {
device = "/dev/vdf";
type = "disk";
content = {
type = "bcachefs";
label = "";
filesystem = "empty_label";
};
};
};

bcachefs_filesystems = {
Expand Down Expand Up @@ -137,6 +147,12 @@
mountpoint = "/home/Documents";
uuid = "64e50034-ebe2-eaf8-1f93-cf56266a8d86";
};

# Example bcachefs filesystem without a label
empty_label = {
type = "bcachefs_filesystem";
mountpoint = "/empty_label";
};
};
};
}
2 changes: 1 addition & 1 deletion lib/types/bcachefs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
default = ''
# Write device arguments to temporary directory for bcachefs_filesystem.
{
printf '%s\n' '--label=${config.label}';
${lib.optionalString (config.label != "") ''printf '%s\n' '--label=${config.label}';''}
${lib.concatMapStrings (args: ''printf '%s\n' '${args}';'') config.extraFormatArgs}
printf '%s\n' '${config.device}';
} >> "$disko_devices_dir/bcachefs-${lib.escapeShellArg config.filesystem}";
Expand Down
7 changes: 7 additions & 0 deletions tests/bcachefs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ diskoLib.testLib.makeDiskoTest {
machine.succeed("mountpoint /home");
machine.succeed("mountpoint /nix");
machine.succeed("mountpoint /home/Documents");
machine.succeed("mountpoint /empty_label")
machine.fail("mountpoint /non-existent");

# Verify device membership and labels.
Expand All @@ -56,9 +57,15 @@ diskoLib.testLib.makeDiskoTest {
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");

## !Warning! device /dev/vde1 in the example config shows up as /dev/vdd1 here
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
## !Warning! device /dev/vdf is the example config shows up as /dev/vde here
machine.succeed("bcachefs show-super /dev/vde | grep -qE '^Label:[[:space:]]+\(none\)'");

machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");


# Verify format arguments.
# Test that lza4 compression and background_compression options were set for vda2.
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
Expand Down