tests: refactor to not use args and to use gpt type

This commit is contained in:
lassulus 2023-07-15 20:42:37 +02:00 committed by mergify[bot]
parent c77e66cea1
commit 04452cfd2b
19 changed files with 221 additions and 335 deletions

View file

@ -1,8 +1,8 @@
{ disks ? [ "/dev/vdb" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
device = builtins.elemAt disks 0; device = "/dev/disk/by-path/pci-0000:02:00.0-nvme-1";
type = "disk"; type = "disk";
content = { content = {
type = "gpt"; type = "gpt";

View file

@ -1,9 +1,9 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
one = { one = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/sda";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@ -12,7 +12,7 @@
type = "EF02"; type = "EF02";
}; };
ESP = { ESP = {
size = "128M"; size = "100M";
type = "EF00"; type = "EF00";
content = { content = {
type = "mdraid"; type = "mdraid";
@ -31,7 +31,7 @@
}; };
two = { two = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 1; device = "/dev/sdb";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@ -73,20 +73,15 @@
type = "mdadm"; type = "mdadm";
level = 1; level = 1;
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions.primary = {
partitions = [ size = "100%";
{ content = {
name = "primary"; type = "filesystem";
start = "1MiB"; format = "ext4";
end = "100%"; mountpoint = "/";
content = { };
type = "filesystem"; };
format = "ext4";
mountpoint = "/";
};
}
];
}; };
}; };
}; };

View file

@ -1,9 +1,9 @@
{ disks ? [ "/dev/vdb" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/disk/by-diskseq/1";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {

View file

@ -1,9 +1,9 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" "/dev/vdd" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
disk0 = { disk0 = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@ -21,7 +21,7 @@
}; };
disk1 = { disk1 = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 1; device = "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00002";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {
@ -47,7 +47,7 @@
}; };
disk2 = { disk2 = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 2; device = "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00003";
content = { content = {
type = "gpt"; type = "gpt";
partitions = { partitions = {

View file

@ -1,9 +1,9 @@
# Example to create a bios compatible gpt partition # Example to create a bios compatible gpt partition
{ disks ? [ "/dev/vdb" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
device = builtins.elemAt disks 0; device = "/dev/vdb";
type = "disk"; type = "disk";
content = { content = {
type = "gpt"; type = "gpt";

View file

@ -1,41 +1,33 @@
{ disks ? [ "/dev/sda" ], ... }: { {
disko.devices = { disko.devices = {
disk.main = { disk.main = {
device = builtins.elemAt disks 0; device = "/dev/disk/by-id/ata-Samsung_SSD_860_EVO_500GB_S3Z1NB0K303456L";
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "1M";
name = "boot"; type = "EF02";
start = "0"; };
end = "1M"; ESP = {
flags = [ "bios_grub" ];
}
{
name = "ESP"; name = "ESP";
start = "1M"; size = "512M";
end = "512M";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
}; };
} };
{ nix = {
name = "nix"; size = "100%";
start = "512M";
end = "100%";
part-type = "primary";
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/nix"; mountpoint = "/nix";
}; };
} };
]; };
}; };
}; };
nodev."/" = { nodev."/" = {

View file

@ -1,41 +1,33 @@
{ disks ? [ "/dev/vda" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
main = { main = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/disk/by-id/ata-Samsung_SSD_850_EVO_250GB_S21PNXAGB12345";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "1M";
name = "boot"; type = "EF02";
start = "0"; };
end = "1M"; ESP = {
flags = [ "bios_grub" ]; size = "512M";
}
{
name = "ESP";
start = "1M";
end = "512M";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
}; };
} };
{ root = {
name = "root"; size = "100%";
start = "512M";
end = "100%";
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,18 +1,14 @@
{ disks ? [ "/dev/vdb" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/vdb";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ ESP = {
{ size = "100M";
name = "ESP";
start = "1MiB";
end = "100MiB";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
@ -21,11 +17,9 @@
"defaults" "defaults"
]; ];
}; };
} };
{ luks = {
name = "luks"; size = "100%";
start = "100MiB";
end = "100%";
content = { content = {
type = "luks"; type = "luks";
name = "crypted"; name = "crypted";
@ -39,8 +33,8 @@
vg = "pool"; vg = "pool";
}; };
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,64 +1,51 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
one = { one = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/sda";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "100M";
name = "boot";
start = "0";
end = "100M";
fs-type = "fat32";
bootable = true;
content = { content = {
type = "mdraid"; type = "mdraid";
name = "boot"; name = "boot";
}; };
} };
{ primary = {
name = "primary"; size = "100%";
start = "100M";
end = "100%";
content = { content = {
type = "lvm_pv"; type = "lvm_pv";
vg = "pool"; vg = "pool";
}; };
} };
]; };
}; };
}; };
two = { two = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 1; device = "/dev/sdb";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{
name = "boot"; name = "boot";
start = "0"; size = "100M";
end = "100M";
fs-type = "fat32";
bootable = true;
content = { content = {
type = "mdraid"; type = "mdraid";
name = "boot"; name = "boot";
}; };
} };
{ primary = {
name = "primary"; size = "100%";
start = "100M";
end = "100%";
content = { content = {
type = "lvm_pv"; type = "lvm_pv";
vg = "pool"; vg = "pool";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,35 +1,29 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
one = { one = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/disk/by-id/ata-VMware_Virtual_SATA_CDRW_Drive_00000000000000000001";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "100M";
name = "boot";
start = "0";
end = "100M";
fs-type = "fat32";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
}; };
} };
{ primary = {
name = "primary"; name = "primary";
start = "100M"; size = "100%";
end = "100%";
content = { content = {
type = "lvm_pv"; type = "lvm_pv";
vg = "pool"; vg = "pool";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,56 +1,44 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/my-disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "1M";
name = "boot"; type = "EF02";
start = "0"; };
end = "1M"; mdadm = {
part-type = "primary"; size = "100%";
flags = [ "bios_grub" ];
}
{
name = "mdadm";
start = "1MiB";
end = "100%";
content = { content = {
type = "mdraid"; type = "mdraid";
name = "raid1"; name = "raid1";
}; };
} };
]; };
}; };
}; };
vdc = { vdc = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 1; device = "/dev/my-disk2";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "1M";
name = "boot"; type = "EF02";
start = "0"; };
end = "1M"; mdadm = {
part-type = "primary"; size = "100%";
flags = [ "bios_grub" ];
}
{
name = "mdadm";
start = "1MiB";
end = "100%";
content = { content = {
type = "mdraid"; type = "mdraid";
name = "raid1"; name = "raid1";
}; };
} };
]; };
}; };
}; };
}; };
@ -59,20 +47,17 @@
type = "mdadm"; type = "mdadm";
level = 1; level = 1;
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ primary = {
{ size = "100%";
name = "primary";
start = "1MiB";
end = "100%";
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,48 +1,38 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
disk0 = { disk0 = {
device = builtins.elemAt disks 0; device = "/dev/vda";
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ nix = {
{ size = "100%";
name = "nix";
part-type = "primary";
start = "0%";
end = "100%";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/a"; mountpoint = "/a";
}; };
} };
]; };
}; };
}; };
disk1 = { disk1 = {
device = builtins.elemAt disks 1; device = "/dev/vdb";
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ root = {
{ size = "100%";
name = "root";
part-type = "primary";
start = "0%";
end = "100%";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/b"; mountpoint = "/b";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,26 +1,21 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
disk0 = { disk0 = {
device = builtins.elemAt disks 0; device = "/dev/disk/by-id/ata-disk0";
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ nix = {
{ end = "-10M";
name = "nix";
part-type = "primary";
start = "0%";
end = "-10MiB";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,47 +1,37 @@
{ disks ? [ "/dev/vdb" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
device = builtins.elemAt disks 0; device = "/dev/vdb";
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ ESP = {
{ size = "100M";
name = "ESP";
start = "1MiB";
end = "100MiB";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
}; };
} };
{ root = {
name = "root";
start = "100MiB";
end = "-1G"; end = "-1G";
part-type = "primary";
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
{ swap = {
name = "swap"; size = "100%";
start = "-1G";
end = "100%";
part-type = "primary";
content = { content = {
type = "swap"; type = "swap";
randomEncryption = true; randomEncryption = true;
resumeDevice = true; # resume from hiberation from this device resumeDevice = true; # resume from hiberation from this device
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,37 +1,29 @@
{ disks ? [ "/dev/vdb" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
device = builtins.elemAt disks 0; device = "/dev/vdb";
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ ESP = {
{ size = "100M";
name = "ESP";
start = "1MiB";
end = "100MiB";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
}; };
} };
{ root = {
name = "root"; size = "100%";
start = "100MiB";
end = "100%";
part-type = "primary";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -1,34 +1,26 @@
# Example to create a bios compatible gpt partition # Example to create a bios compatible gpt partition
{ disks ? [ "/dev/vdb" ], lib, ... }: { { disks ? [ "/dev/vdb" ], lib, ... }: {
disko.devices = { disko.devices = {
disk = lib.genAttrs [ (lib.head disks) ] (device: { disk = lib.genAttrs disks (device: {
name = lib.replaceStrings [ "/" ] [ "_" ] device;
device = device; device = device;
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ boot = {
{ size = "1M";
name = "boot"; type = "EF02";
start = "0"; };
end = "1M"; root = {
part-type = "primary"; size = "100%";
flags = [ "bios_grub" ];
}
{
name = "root";
# leave space for the grub aka BIOS boot
start = "1M";
end = "100%";
part-type = "primary";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
]; };
}; };
}); });
}; };

View file

@ -1,18 +1,14 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
vdb = { vdb = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/vdb";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ ESP = {
{ size = "100M";
name = "ESP";
start = "1MiB";
end = "100MiB";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
@ -21,24 +17,21 @@
"defaults" "defaults"
]; ];
}; };
} };
{ primary = {
start = "100MiB"; size = "100%";
end = "100%";
name = "primary";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "ext4"; format = "ext4";
mountpoint = "/"; mountpoint = "/";
}; };
} };
]; };
}; };
}; };
vdc = { vdc = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 1; device = "/dev/vdc";
content = { content = {
type = "zfs"; type = "zfs";
pool = "zroot"; pool = "zroot";

View file

@ -1,54 +1,44 @@
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: { {
disko.devices = { disko.devices = {
disk = { disk = {
x = { x = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 0; device = "/dev/sdx";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ ESP = {
{ size = "64M";
name = "ESP";
start = "0";
end = "64MiB";
fs-type = "fat32";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
}; };
} };
{ zfs = {
name = "zfs"; size = "100%";
start = "128MiB";
end = "100%";
content = { content = {
type = "zfs"; type = "zfs";
pool = "zroot"; pool = "zroot";
}; };
} };
]; };
}; };
}; };
y = { y = {
type = "disk"; type = "disk";
device = builtins.elemAt disks 1; device = "/dev/sdy";
content = { content = {
type = "table"; type = "gpt";
format = "gpt"; partitions = {
partitions = [ zfs = {
{ size = "100%";
name = "zfs";
start = "128MiB";
end = "100%";
content = { content = {
type = "zfs"; type = "zfs";
pool = "zroot"; pool = "zroot";
}; };
} };
]; };
}; };
}; };
}; };

View file

@ -52,10 +52,15 @@ let
}; };
devices = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf"]; devices = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf"];
# for installation we skip /dev/vda because it is the test runner disk # for installation we skip /dev/vda because it is the test runner disk
testConfigInstall = testlib.prepareDiskoConfig (import disko-config { inherit lib; }) (lib.tail devices); importedDiskoConfig = import disko-config;
diskoConfigWithArgs = if builtins.isFunction importedDiskoConfig then
importedDiskoConfig { inherit lib; }
else
importedDiskoConfig;
testConfigInstall = testlib.prepareDiskoConfig diskoConfigWithArgs (lib.tail devices);
# we need to shift the disks by one because the first disk is the /dev/vda of the test runner # we need to shift the disks by one because the first disk is the /dev/vda of the test runner
# so /dev/vdb becomes /dev/vda etc. # so /dev/vdb becomes /dev/vda etc.
testConfigBooted = testlib.prepareDiskoConfig (import disko-config { inherit lib; }) devices; testConfigBooted = testlib.prepareDiskoConfig diskoConfigWithArgs devices;
tsp-generator = pkgs.callPackage ../. { checked = true; }; tsp-generator = pkgs.callPackage ../. { checked = true; };
tsp-create = (tsp-generator.createScript testConfigInstall) pkgs; tsp-create = (tsp-generator.createScript testConfigInstall) pkgs;