nixosTests.virtualbox: allow additional parameters for tests

This commit is contained in:
Julian Stecklina 2024-02-14 17:29:06 +01:00
parent a9822fa200
commit 77c7ac6c35

View File

@ -340,7 +340,7 @@ let
testExtensionPack.vmFlags = enableExtensionPackVMFlags; testExtensionPack.vmFlags = enableExtensionPackVMFlags;
}; };
mkVBoxTest = useExtensionPack: vms: name: testScript: makeTest { mkVBoxTest = vboxHostConfig: vms: name: testScript: makeTest {
name = "virtualbox-${name}"; name = "virtualbox-${name}";
nodes.machine = { lib, config, ... }: { nodes.machine = { lib, config, ... }: {
@ -350,13 +350,16 @@ let
in [ ./common/user-account.nix ./common/x11.nix ] ++ vmConfigs; in [ ./common/user-account.nix ./common/x11.nix ] ++ vmConfigs;
virtualisation.memorySize = 2048; virtualisation.memorySize = 2048;
virtualisation.qemu.options = ["-cpu" "kvm64,svm=on,vmx=on"]; virtualisation.qemu.options = ["-cpu" "kvm64,svm=on,vmx=on"];
virtualisation.virtualbox.host.enable = true;
test-support.displayManager.auto.user = "alice"; test-support.displayManager.auto.user = "alice";
users.users.alice.extraGroups = let users.users.alice.extraGroups = let
inherit (config.virtualisation.virtualbox.host) enableHardening; inherit (config.virtualisation.virtualbox.host) enableHardening;
in lib.mkIf enableHardening (lib.singleton "vboxusers"); in lib.mkIf enableHardening [ "vboxusers" ];
virtualisation.virtualbox.host.enableExtensionPack = useExtensionPack;
nixpkgs.config.allowUnfree = useExtensionPack; virtualisation.virtualbox.host = {
enable = true;
} // vboxHostConfig;
nixpkgs.config.allowUnfree = config.virtualisation.virtualbox.host.enableExtensionPack;
}; };
testScript = '' testScript = ''
@ -390,7 +393,7 @@ let
}; };
}; };
unfreeTests = mapAttrs (mkVBoxTest true vboxVMsWithExtpack) { unfreeTests = mapAttrs (mkVBoxTest { enableExtensionPack = true; } vboxVMsWithExtpack) {
enable-extension-pack = '' enable-extension-pack = ''
create_vm_testExtensionPack() create_vm_testExtensionPack()
vbm("startvm testExtensionPack") vbm("startvm testExtensionPack")
@ -409,7 +412,7 @@ let
''; '';
}; };
in mapAttrs (mkVBoxTest false vboxVMs) { in mapAttrs (mkVBoxTest {} vboxVMs) {
simple-gui = '' simple-gui = ''
# Home to select Tools, down to move to the VM, enter to start it. # Home to select Tools, down to move to the VM, enter to start it.
def send_vm_startup(): def send_vm_startup():