summaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-10-21 14:43:55 +0200
committerlassulus <lassulus@lassul.us>2022-10-23 11:34:39 +0200
commit8666475b74ecd15bcf546f554c0587f496cd9c8f (patch)
tree9298c60e650ad305aa15eee82ca392b6d73bc839 /example
parentc96ccd7d9fb48b8283e84811c2355a3c39bb2a52 (diff)
tests: pass lib to examples
Diffstat (limited to 'example')
-rw-r--r--example/boot-raid1.nix2
-rw-r--r--example/btrfs-subvolumes.nix2
-rw-r--r--example/complex.nix2
-rw-r--r--example/gpt-bios-compat.nix2
-rw-r--r--example/luks-lvm.nix2
-rw-r--r--example/lvm-raid.nix2
-rw-r--r--example/mdadm.nix2
-rw-r--r--example/with-lib.nix35
-rw-r--r--example/zfs-over-legacy.nix2
-rw-r--r--example/zfs.nix2
10 files changed, 44 insertions, 9 deletions
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";