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 = {
disk = {
vdb = {
device = builtins.elemAt disks 0;
device = "/dev/disk/by-path/pci-0000:02:00.0-nvme-1";
type = "disk";
content = {
type = "gpt";

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -52,10 +52,15 @@ let
};
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
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
# 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-create = (tsp-generator.createScript testConfigInstall) pkgs;