diff --git a/example/zfs-with-vdevs.nix b/example/zfs-with-vdevs.nix index 985e082c..effe53e1 100644 --- a/example/zfs-with-vdevs.nix +++ b/example/zfs-with-vdevs.nix @@ -244,11 +244,14 @@ type = "topology"; vdev = [ { - mode = "mirror"; - members = [ "data1" "data2" ]; + # This syntax expects a disk called 'data3' with a gpt partition called 'zfs'. + members = [ "data1" ]; + # It's also possible to use the full path of the device or partition + # members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ]; } { - members = [ "data3" ]; + mode = "mirror"; + members = [ "data2" "data3" ]; } ]; spare = [ "spare" ]; diff --git a/lib/types/zpool.nix b/lib/types/zpool.nix index 9e0d5b26..80340484 100644 --- a/lib/types/zpool.nix +++ b/lib/types/zpool.nix @@ -25,6 +25,44 @@ in }; mode = lib.mkOption { default = ""; + example = { + mode = { + topology = { + type = "topology"; + vdev = [ + { + # Members can be either specified by a full path or by a disk name + # This is example uses the full path + members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ]; + } + ]; + log = [ + { + # Example using gpt partition labels + # This expects an disk called `ssd` with a gpt partition called `zfs` + # disko.devices.disk.ssd = { + # type = "disk"; + # device = "/dev/nvme0n1"; + # content = { + # type = "gpt"; + # partitions = { + # zfs = { + # size = "100%"; + # content = { + # type = "zfs"; + # # use your own pool name here + # pool = "zroot"; + # }; + # }; + # }; + # }; + # }; + members = [ "ssd" ]; + } + ]; + }; + }; + }; type = (lib.types.oneOf [ (lib.types.enum modeOptions) (lib.types.attrsOf (diskoLib.subType { diff --git a/tests/zfs-with-vdevs.nix b/tests/zfs-with-vdevs.nix index 704a1733..6b9e2d55 100644 --- a/tests/zfs-with-vdevs.nix +++ b/tests/zfs-with-vdevs.nix @@ -57,9 +57,9 @@ diskoLib.testLib.makeDiskoTest { vdev = "" actual.sort() expected=sorted([ - 'zroot /dev/disk/by-partlabel/disk-data3-zfs', - 'zroot mirror /dev/disk/by-partlabel/disk-data1-zfs', + 'zroot /dev/disk/by-partlabel/disk-data1-zfs', 'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs', + 'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs', 'dedup /dev/disk/by-partlabel/disk-dedup3-zfs', 'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs', 'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',