diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2020-10-25 13:19:25 +0100 |
---|---|---|
committer | Andreas Rammhold <andreas@rammhold.de> | 2020-10-25 13:42:01 +0100 |
commit | f4d74931628accc733f9e0e996575b5ca3042d8a (patch) | |
tree | c6d913eba7e3f45e8796b0e54f916d15cc57b0db /nixos/modules/testing/test-instrumentation.nix | |
parent | aa7977af2c0468eb4ab91cf9144564a70a1f08c8 (diff) | |
download | nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.tar nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.tar.gz nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.tar.bz2 nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.tar.lz nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.tar.xz nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.tar.zst nixpkgs-f4d74931628accc733f9e0e996575b5ca3042d8a.zip |
nixos/tests: only apply qemu parameters if the options are defined
This fixes an eval error that occurred on hydra with the small channel and the `nixos.tests.boot.biosCdrom.x86_64-linux` attribute: > $ nix-instantiate nixos/release-small.nix -A nixos.tests.boot.biosCdrom.x86_64-linux > warning: unknown setting 'experimental-features' > error: The option `virtualisation.qemu' does not exist. Definition values: > - In `/home/andi/dev/nixos/nixpkgs/nixos/modules/testing/test-instrumentation.nix': > { > consoles = [ ]; > package = { > _type = "override"; > content = <derivation /nix/store/q72h2cdcb9zjgiay5gdgzwddjkbjr7xq-qemu-host-cpu-only-for-vm-tests-5.1.0.drv>; > ... > (use '--show-trace' to show detailed location information) In bc2188b we changed test test-instrumentation to also set the QEMU package that is being used. That change unfortunately caused us to always assing values to the virtualisation.qemu.package option even when the option is not defined. The original code was explicitly testing for the consoles case but the then newly extended version did not adjust the check as the intention was probably not clear. With this commit we are always ensuring the entire virtualisation.qemu section exists and can thus drop the individual tests for each of the sections since the QEMU module always defines both the package and the consoles option when it's root is defined..
Diffstat (limited to 'nixos/modules/testing/test-instrumentation.nix')
-rw-r--r-- | nixos/modules/testing/test-instrumentation.nix | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 2986bd4c4e3..be5fa88b8ad 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -45,15 +45,21 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; systemd.services."serial-getty@${qemuSerialDevice}".enable = false; systemd.services."serial-getty@hvc0".enable = false; - # Only use a serial console, no TTY. - # NOTE: optionalAttrs - # test-instrumentation.nix appears to be used without qemu-vm.nix, so - # we avoid defining consoles if not possible. - # TODO: refactor such that test-instrumentation can import qemu-vm - # or declare virtualisation.qemu.console option in a module that's always imported - virtualisation.qemu = { - consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice; - package = lib.mkDefault pkgs.qemu_test; + # Only set these settings when the options exist. Some tests (e.g. those + # that do not specify any nodes, or an empty attr set as nodes) will not + # have the QEMU module loaded and thuse these options can't and should not + # be set. + virtualisation = lib.optionalAttrs (options ? virtualisation.qemu) { + qemu = { + # Only use a serial console, no TTY. + # NOTE: optionalAttrs + # test-instrumentation.nix appears to be used without qemu-vm.nix, so + # we avoid defining consoles if not possible. + # TODO: refactor such that test-instrumentation can import qemu-vm + # or declare virtualisation.qemu.console option in a module that's always imported + consoles = [ qemuSerialDevice ]; + package = lib.mkDefault pkgs.qemu_test; + }; }; boot.initrd.preDeviceCommands = |