add nixos tests for disko.config, extend/fix existing tests

This commit is contained in:
lassulus 2022-09-30 12:55:28 +02:00
parent a215a19759
commit 9f7f23abdb
22 changed files with 448 additions and 110 deletions

117
example/boot-raid1.nix Normal file
View file

@ -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 = "/";
};
}
];
};
};
};
}

View file

@ -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";

View file

@ -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";
};
}
];

View file

@ -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;
}

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

@ -1,12 +1,20 @@
{
{ 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";
@ -22,11 +30,19 @@
};
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";
@ -57,7 +73,7 @@
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/raid";
mountpoint = "/";
};
}
];

View file

@ -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";
};
};

View file

@ -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";
};
}
];
};
};
};