testLib.makeDiskoTest: split extraConfig into nixos-config, extraSystemConfig & extraInstallerConfig

This commit is contained in:
lassulus 2023-07-15 16:57:18 +02:00 committed by mergify[bot]
parent 056637d3c9
commit 715c211dd7
10 changed files with 46 additions and 40 deletions

View file

@ -32,10 +32,12 @@ let
makeDiskoTest =
{ name
, disko-config
, nixos-config ? null
, pkgs ? import <nixpkgs> { }
, extraTestScript ? ""
, bootCommands ? ""
, extraConfig ? { }
, extraInstallerConfig ? { }
, extraSystemConfig ? { }
, grub-devices ? [ "nodev" ]
, efi ? true
, postDisko ? ""
@ -62,7 +64,17 @@ let
tsp-config = tsp-generator.config testConfigBooted;
num-disks = builtins.length (lib.attrNames testConfigBooted.disko.devices.disk);
installed-system = { modulesPath, ... }: {
imports = [
# we always want the bind-mounted nix store. otherwise tests take forever
fileSystems."/nix/store" = lib.mkForce {
device = "nix-store";
fsType = "9p";
neededForBoot = true;
options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ];
};
imports = (if nixos-config != null then [
nixos-config
] else [
(lib.optionalAttrs (testMode == "direct" || testMode == "cli") tsp-config)
(lib.optionalAttrs (testMode == "module") {
disko.enableConfig = true;
@ -71,31 +83,27 @@ let
testConfigBooted
];
})
(modulesPath + "/testing/test-instrumentation.nix")
(modulesPath + "/profiles/qemu-guest.nix")
(modulesPath + "/profiles/minimal.nix")
extraConfig
];
fileSystems."/nix/store" = {
device = "nix-store";
fsType = "9p";
neededForBoot = true;
options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ];
};
documentation.enable = false;
hardware.enableAllFirmware = lib.mkForce false;
networking.hostId = "8425e349"; # from profiles/base.nix, needed for zfs
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
boot.initrd.preDeviceCommands = ''
echo -n 'secretsecret' > /tmp/secret.key
'';
{ # config for tests to make them run faster or work at all
documentation.enable = false;
hardware.enableAllFirmware = lib.mkForce false;
networking.hostId = "8425e349"; # from profiles/base.nix, needed for zfs
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
boot.initrd.preDeviceCommands = ''
echo -n 'secretsecret' > /tmp/secret.key
'';
boot.consoleLogLevel = lib.mkForce 100;
boot.loader.grub = {
devices = grub-devices;
efiSupport = efi;
efiInstallAsRemovable = efi;
};
boot.consoleLogLevel = lib.mkForce 100;
boot.loader.grub = {
devices = grub-devices;
efiSupport = efi;
efiInstallAsRemovable = efi;
};
}
]) ++ [
(modulesPath + "/testing/test-instrumentation.nix") # we need these 2 modules always to be able to run the tests
(modulesPath + "/profiles/qemu-guest.nix")
extraSystemConfig
];
};
installed-system-eval = eval-config {
modules = [ installed-system ];
@ -128,7 +136,7 @@ let
})
(modulesPath + "/profiles/base.nix")
(modulesPath + "/profiles/minimal.nix")
extraConfig
extraInstallerConfig
];
environment.systemPackages = [
pkgs.jq

View file

@ -10,7 +10,7 @@ makeDiskoTest {
machine.succeed("lsblk >&2");
'';
# so that the installer boots with a bcachefs enabled kernel
extraConfig = {
extraInstallerConfig = {
boot.supportedFilesystems = [ "bcachefs" ];
# disable zfs so we can support latest kernel
nixpkgs.overlays = [

View file

@ -5,7 +5,7 @@ makeDiskoTest {
inherit pkgs;
name = "cli";
disko-config = ../example/complex.nix;
extraConfig = {
extraSystemConfig = {
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
};
testMode = "cli";
@ -19,7 +19,7 @@ makeDiskoTest {
machine.succeed("mountpoint /ext4onzfs");
machine.succeed("mountpoint /ext4_on_lvm");
'';
extraConfig = {
extraInstallerConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ];
};
}

View file

@ -5,7 +5,7 @@ makeDiskoTest {
inherit pkgs;
name = "complex";
disko-config = ../example/complex.nix;
extraConfig = {
extraSystemConfig = {
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
};
extraTestScript = ''
@ -18,7 +18,7 @@ makeDiskoTest {
machine.succeed("mountpoint /ext4onzfs");
machine.succeed("mountpoint /ext4_on_lvm");
'';
extraConfig = {
extraInstallerConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ];
};
}

View file

@ -10,7 +10,7 @@ let
allTestFilenames =
builtins.map (lib.removeSuffix ".nix") (
builtins.filter
(x: lib.hasSuffix ".nix" x && x != "default.nix" && x != "lib.nix")
(x: lib.hasSuffix ".nix" x && x != "default.nix")
(lib.attrNames (builtins.readDir ./.))
);

View file

@ -5,7 +5,6 @@ makeDiskoTest {
inherit pkgs;
name = "luks-lvm";
disko-config = ../example/luks-lvm.nix;
extraConfig.boot.initrd.luks.devices.crypted.preLVM = false;
extraTestScript = ''
machine.succeed("cryptsetup isLuks /dev/vda2");
machine.succeed("mountpoint /home");

View file

@ -8,7 +8,7 @@ makeDiskoTest {
extraTestScript = ''
machine.succeed("mountpoint /home");
'';
extraConfig = {
extraInstallerConfig = {
boot.kernelModules = [ "dm-raid0" "dm-mirror" ];
};
}

View file

@ -5,7 +5,7 @@ makeDiskoTest {
inherit pkgs;
name = "module";
disko-config = ../example/complex.nix;
extraConfig = {
extraSystemConfig = {
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
};
testMode = "module";
@ -19,7 +19,7 @@ makeDiskoTest {
machine.succeed("mountpoint /ext4onzfs");
machine.succeed("mountpoint /ext4_on_lvm");
'';
extraConfig = {
extraInstallerConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ];
};
}

View file

@ -18,7 +18,7 @@ makeDiskoTest {
'
""");
'';
extraConfig = {
extraSystemConfig = {
environment.systemPackages = [ pkgs.jq ];
};
}

View file

@ -5,9 +5,8 @@ makeDiskoTest {
inherit pkgs;
name = "zfs";
disko-config = ../example/zfs.nix;
extraConfig = {
extraSystemConfig = {
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
boot.zfs.requestEncryptionCredentials = true;
};
extraTestScript = ''
machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");