From 8666475b74ecd15bcf546f554c0587f496cd9c8f Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 21 Oct 2022 14:43:55 +0200 Subject: tests: pass lib to examples --- example/boot-raid1.nix | 2 +- example/btrfs-subvolumes.nix | 2 +- example/complex.nix | 2 +- example/gpt-bios-compat.nix | 2 +- example/luks-lvm.nix | 2 +- example/lvm-raid.nix | 2 +- example/mdadm.nix | 2 +- example/with-lib.nix | 35 +++++++++++++++++++++++++++++++++++ example/zfs-over-legacy.nix | 2 +- example/zfs.nix | 2 +- 10 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 example/with-lib.nix (limited to 'example') diff --git a/example/boot-raid1.nix b/example/boot-raid1.nix index c930eb5..dfd2e6c 100644 --- a/example/boot-raid1.nix +++ b/example/boot-raid1.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: { +{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { disk = { one = { type = "disk"; diff --git a/example/btrfs-subvolumes.nix b/example/btrfs-subvolumes.nix index 9a22861..02ce2a4 100644 --- a/example/btrfs-subvolumes.nix +++ b/example/btrfs-subvolumes.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" ] }: { +{ disks ? [ "/dev/vdb" ], ... }: { disk = { vdb = { type = "disk"; diff --git a/example/complex.nix b/example/complex.nix index 7ee9282..f2204a6 100644 --- a/example/complex.nix +++ b/example/complex.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: { +{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { disk = { disk0 = { type = "disk"; diff --git a/example/gpt-bios-compat.nix b/example/gpt-bios-compat.nix index 72886a0..7275e26 100644 --- a/example/gpt-bios-compat.nix +++ b/example/gpt-bios-compat.nix @@ -1,5 +1,5 @@ # Example to create a bios compatible gpt partition -{ disks ? [ "/dev/vdb" ] }: { +{ disks ? [ "/dev/vdb" ], ... }: { disk = { vdb = { device = builtins.elemAt disks 0; diff --git a/example/luks-lvm.nix b/example/luks-lvm.nix index fdaba8c..8ffb273 100644 --- a/example/luks-lvm.nix +++ b/example/luks-lvm.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" ] }: { +{ disks ? [ "/dev/vdb" ], ... }: { disk = { vdb = { type = "disk"; diff --git a/example/lvm-raid.nix b/example/lvm-raid.nix index 9d0c9d7..8622238 100644 --- a/example/lvm-raid.nix +++ b/example/lvm-raid.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: { +{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { disk = { one = { type = "disk"; diff --git a/example/mdadm.nix b/example/mdadm.nix index 8093698..132ead5 100644 --- a/example/mdadm.nix +++ b/example/mdadm.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: { +{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { disk = { vdb = { type = "disk"; diff --git a/example/with-lib.nix b/example/with-lib.nix new file mode 100644 index 0000000..e746f5b --- /dev/null +++ b/example/with-lib.nix @@ -0,0 +1,35 @@ +# Example to create a bios compatible gpt partition +{ disks ? [ "/dev/vdb" ], lib, ... }: { + disk = lib.traceValSeq (lib.genAttrs [ (lib.head disks) ] (device: { + device = device; + type = "disk"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + name = "boot"; + type = "partition"; + start = "0"; + end = "1M"; + part-type = "primary"; + flags = ["bios_grub"]; + } + { + name = "root"; + type = "partition"; + # leave space for the grub aka BIOS boot + start = "1M"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + } + ]; + }; + })); +} diff --git a/example/zfs-over-legacy.nix b/example/zfs-over-legacy.nix index 9943278..974af35 100644 --- a/example/zfs-over-legacy.nix +++ b/example/zfs-over-legacy.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: { +{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { disk = { vdb = { type = "disk"; diff --git a/example/zfs.nix b/example/zfs.nix index 92ed688..59c3f24 100644 --- a/example/zfs.nix +++ b/example/zfs.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: { +{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { disk = { x = { type = "disk"; -- cgit v1.2.3