summaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2022-10-04 11:30:22 +0200
committerGitHub <noreply@github.com>2022-10-04 11:30:22 +0200
commitc96ccd7d9fb48b8283e84811c2355a3c39bb2a52 (patch)
tree5cdd04282099d607d86c961e390077b09f50452b /example
parent60b5f5e7495dd90b8212d121905feaee313fef8f (diff)
parent9f7f23abdb161578316d94f45528fbf47982f4d9 (diff)
Merge pull request #43 from nix-community/test-config
add nixos tests for disko.config
Diffstat (limited to 'example')
-rw-r--r--example/boot-raid1.nix117
-rw-r--r--example/btrfs-subvolumes.nix19
-rw-r--r--example/complex.nix49
-rw-r--r--example/default.nix14
-rw-r--r--example/gpt-bios-compat.nix4
-rw-r--r--example/luks-lvm.nix6
-rw-r--r--example/lvm-raid.nix50
-rw-r--r--example/mdadm.nix24
-rw-r--r--example/zfs-over-legacy.nix31
-rw-r--r--example/zfs.nix55
10 files changed, 300 insertions, 69 deletions
diff --git a/example/boot-raid1.nix b/example/boot-raid1.nix
new file mode 100644
index 0000000..c930eb5
--- /dev/null
+++ b/example/boot-raid1.nix
@@ -0,0 +1,117 @@
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
+ disk = {
+ one = {
+ type = "disk";
+ device = builtins.elemAt disks 0;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
+ type = "partition";
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
+ type = "partition";
+ name = "mdadm";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "mdraid";
+ name = "raid1";
+ };
+ }
+ ];
+ };
+ };
+ two = {
+ type = "disk";
+ device = builtins.elemAt disks 1;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
+ type = "partition";
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
+ type = "partition";
+ name = "mdadm";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "mdraid";
+ name = "raid1";
+ };
+ }
+ ];
+ };
+ };
+ };
+ mdadm = {
+ boot = {
+ type = "mdadm";
+ level = 1;
+ metadata = "1.0";
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ };
+ raid1 = {
+ type = "mdadm";
+ level = 1;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ type = "partition";
+ name = "primary";
+ start = "1MiB";
+ end = "100%";
+ content = {
+ type = "filesystem";
+ format = "ext4";
+ mountpoint = "/";
+ };
+ }
+ ];
+ };
+ };
+ };
+}
diff --git a/example/btrfs-subvolumes.nix b/example/btrfs-subvolumes.nix
index 83ea71e..9a22861 100644
--- a/example/btrfs-subvolumes.nix
+++ b/example/btrfs-subvolumes.nix
@@ -1,16 +1,29 @@
-{
+{ disks ? [ "/dev/vdb" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ type = "partition";
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ }
+ {
name = "root";
type = "partition";
- start = "0%";
+ start = "128MiB";
end = "100%";
content = {
type = "btrfs";
diff --git a/example/complex.nix b/example/complex.nix
index 078f9c5..7ee9282 100644
--- a/example/complex.nix
+++ b/example/complex.nix
@@ -1,25 +1,40 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
- disk1 = {
+ disk0 = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
- start = "0";
- end = "1M";
- name = "grub";
- flags = ["bios_grub"];
+ name = "ESP";
+ start = "1MiB";
+ end = "128MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
}
+ ];
+ };
+ };
+ disk1 = {
+ type = "disk";
+ device = builtins.elemAt disks 1;
+ content = {
+ type = "table";
+ format = "gpt";
+ partitions = [
{
type = "partition";
start = "1M";
end = "100%";
name = "luks";
- bootable = true;
content = {
type = "luks";
name = "crypted1";
@@ -39,24 +54,16 @@
};
disk2 = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 2;
content = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
- start = "0";
- end = "1M";
- name = "grub";
- flags = ["bios_grub"];
- }
- {
- type = "partition";
start = "1M";
end = "100%";
name = "luks";
- bootable = true;
content = {
type = "luks";
name = "crypted2";
@@ -81,17 +88,17 @@
level = 1;
content = {
type = "table";
- format = "msdos";
+ format = "gpt";
partitions = [
{
type = "partition";
- name = "xfs";
+ name = "bla";
start = "1MiB";
end = "100%";
content = {
type = "filesystem";
- format = "xfs";
- mountpoint = "/xfs_mdadm_lvm";
+ format = "ext4";
+ mountpoint = "/ext4_mdadm_lvm";
};
}
];
diff --git a/example/default.nix b/example/default.nix
deleted file mode 100644
index e69c8db..0000000
--- a/example/default.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-# usage: nix-instantiate --eval --json --strict example | jq -r .
-
-let
- cfg = import ./config.nix;
- #cfg = import ./config-gpt-bios.nix;
-in
-# TODO: get rid of NIX_PATH dependency here
-with import ../. {};
-
-{
- config = config cfg;
- create = create cfg;
- mount = mount cfg;
-}
diff --git a/example/gpt-bios-compat.nix b/example/gpt-bios-compat.nix
index 9abe691..72886a0 100644
--- a/example/gpt-bios-compat.nix
+++ b/example/gpt-bios-compat.nix
@@ -1,8 +1,8 @@
# Example to create a bios compatible gpt partition
-{
+{ disks ? [ "/dev/vdb" ] }: {
disk = {
vdb = {
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
type = "disk";
content = {
type = "table";
diff --git a/example/luks-lvm.nix b/example/luks-lvm.nix
index 17e18a2..fdaba8c 100644
--- a/example/luks-lvm.nix
+++ b/example/luks-lvm.nix
@@ -1,8 +1,8 @@
-{
+{ disks ? [ "/dev/vdb" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
@@ -10,7 +10,6 @@
{
type = "partition";
name = "ESP";
- # fs-type = "FAT32";
start = "1MiB";
end = "100MiB";
bootable = true;
@@ -34,7 +33,6 @@
keyFile = "/tmp/secret.key";
extraArgs = [
"--hash sha512"
- "--iter-time 5000"
];
content = {
type = "lvm_pv";
diff --git a/example/lvm-raid.nix b/example/lvm-raid.nix
index 3c5ee69..9d0c9d7 100644
--- a/example/lvm-raid.nix
+++ b/example/lvm-raid.nix
@@ -1,16 +1,28 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
- vdb = {
+ one = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "100M";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
type = "partition";
name = "primary";
- start = "0%";
+ start = "100M";
end = "100%";
content = {
type = "lvm_pv";
@@ -20,17 +32,29 @@
];
};
};
- vdc = {
+ two = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "100M";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "mdraid";
+ name = "boot";
+ };
+ }
+ {
type = "partition";
name = "primary";
- start = "0%";
+ start = "100M";
end = "100%";
content = {
type = "lvm_pv";
@@ -41,6 +65,18 @@
};
};
};
+ mdadm = {
+ boot = {
+ type = "mdadm";
+ level = 1;
+ metadata = "1.0";
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ };
+ };
lvm_vg = {
pool = {
type = "lvm_vg";
diff --git a/example/mdadm.nix b/example/mdadm.nix
index 094499d..8093698 100644
--- a/example/mdadm.nix
+++ b/example/mdadm.nix
@@ -1,13 +1,21 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
type = "partition";
name = "mdadm";
start = "1MiB";
@@ -22,12 +30,20 @@
};
vdc = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
type = "table";
format = "gpt";
partitions = [
{
+ name = "boot";
+ type = "partition";
+ start = "0";
+ end = "1M";
+ part-type = "primary";
+ flags = ["bios_grub"];
+ }
+ {
type = "partition";
name = "mdadm";
start = "1MiB";
@@ -57,7 +73,7 @@
content = {
type = "filesystem";
format = "ext4";
- mountpoint = "/raid";
+ mountpoint = "/";
};
}
];
diff --git a/example/zfs-over-legacy.nix b/example/zfs-over-legacy.nix
index 81a5975..9943278 100644
--- a/example/zfs-over-legacy.nix
+++ b/example/zfs-over-legacy.nix
@@ -1,15 +1,30 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
vdb = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
type = "partition";
- start = "0%";
+ name = "ESP";
+ start = "1MiB";
+ end = "100MiB";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ options = [
+ "defaults"
+ ];
+ };
+ }
+ {
+ type = "partition";
+ start = "100MiB";
end = "100%";
name = "primary";
bootable = true;
@@ -24,7 +39,7 @@
};
vdc = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
type = "zfs";
pool = "zroot";
@@ -34,10 +49,16 @@
zpool = {
zroot = {
type = "zpool";
+ rootFsOptions.mountpoint = "none";
datasets = {
- zfs_fs = {
+ "root" = {
+ zfs_type = "filesystem";
+ options.mountpoint = "none";
+ };
+ "root/zfs_fs" = {
zfs_type = "filesystem";
mountpoint = "/zfs_fs";
+ options.mountpoint = "/zfs_fs";
options."com.sun:auto-snapshot" = "true";
};
};
diff --git a/example/zfs.nix b/example/zfs.nix
index 16da367..92ed688 100644
--- a/example/zfs.nix
+++ b/example/zfs.nix
@@ -1,19 +1,56 @@
-{
+{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
disk = {
- vdb = {
+ x = {
type = "disk";
- device = "/dev/vdb";
+ device = builtins.elemAt disks 0;
content = {
- type = "zfs";
- pool = "zroot";
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ type = "partition";
+ name = "ESP";
+ start = "0";
+ end = "64MiB";
+ fs-type = "fat32";
+ bootable = true;
+ content = {
+ type = "filesystem";
+ format = "vfat";
+ mountpoint = "/boot";
+ };
+ }
+ {
+ type = "partition";
+ name = "zfs";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "zfs";
+ pool = "zroot";
+ };
+ }
+ ];
};
};
- vdc = {
+ y = {
type = "disk";
- device = "/dev/vdc";
+ device = builtins.elemAt disks 1;
content = {
- type = "zfs";
- pool = "zroot";
+ type = "table";
+ format = "gpt";
+ partitions = [
+ {
+ type = "partition";
+ name = "zfs";
+ start = "128MiB";
+ end = "100%";
+ content = {
+ type = "zfs";
+ pool = "zroot";
+ };
+ }
+ ];
};
};
};