types btrfs: fix format without swap or subvolumes

This commit is contained in:
Kira Bruneau 2024-04-07 16:49:23 -04:00 committed by mergify[bot]
parent 9e0bf2fe7f
commit 79eab0e82c
3 changed files with 73 additions and 23 deletions

View File

@ -0,0 +1,37 @@
{
disko.devices = {
disk = {
vdb = {
type = "disk";
device = "/dev/disk/by-diskseq/1";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
name = "ESP";
start = "1M";
end = "128M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
};
};
};
};
};
};
};
}

View File

@ -120,6 +120,7 @@ in
if ! (blkid '${config.device}' -o export | grep -q '^TYPE='); then
mkfs.btrfs "${config.device}" ${toString config.extraArgs}
fi
${lib.optionalString (config.swap != {} || config.subvolumes != {}) ''
if (blkid "${config.device}" -o export | grep -q '^TYPE=btrfs$'); then
${lib.optionalString (config.swap != {}) ''
(
@ -143,6 +144,7 @@ in
)
'') (lib.attrValues config.subvolumes)}
fi
''}
'';
};
_mount = diskoLib.mkMountOption {

View File

@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> { }
, diskoLib ? pkgs.callPackage ../lib { }
}:
diskoLib.testLib.makeDiskoTest {
inherit pkgs;
name = "btrfs-only-root-subvolume";
disko-config = ../example/btrfs-only-root-subvolume.nix;
extraTestScript = ''
machine.succeed("btrfs subvolume list /");
'';
}