From 257855753073987160c293fdedc9d95a33cbc0e8 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 16 Aug 2020 13:50:51 +0200 Subject: nixos/test-instrumentation.nix: Fix evaluation error Discovered via https://github.com/NixOS/nixpkgs/pull/82743 which improved option checking, causing an evaluation error that was hard to understand without running the evaluation manually. --- nixos/modules/testing/test-instrumentation.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 1baeab53b0c..a6b34e36d20 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -55,7 +55,12 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; systemd.services."serial-getty@hvc0".enable = false; # Only use a serial console, no TTY. - virtualisation.qemu.consoles = [ qemuSerialDevice ]; + # 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 = lib.optionalAttrs (options ? virtualisation.qemu.consoles) { qemu.consoles = [ qemuSerialDevice ]; }; boot.initrd.preDeviceCommands = '' -- cgit 1.4.1 From 2fbddb0ccb9ad539f1b4a96ea5bc0247dff6da25 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 18 Aug 2020 12:24:02 +0200 Subject: nixos/test-instrumentation: properly import `options` for `qemu`-check If `qemu-vm.nix` is imported, the option `virtualisation.qemu.consoles` should be set to make sure that the machine's output isn't rendered on the graphical window of QEMU. This is needed when interactively running a NixOS test or in conjunction with `nixos-build-vms(8)`. The patch 257855753073987160c293fdedc9d95a33cbc0e8 tries to only do this if the option actually exists, however this condition used to be always false since `options` wasn't imported in the module and pointed to `lib.options` due to the `with lib;`-clause. --- nixos/modules/testing/test-instrumentation.nix | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index a6b34e36d20..30ffb12cbad 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -1,22 +1,13 @@ # This module allows the test driver to connect to the virtual machine # via a root shell attached to port 514. -{ config, lib, pkgs, ... }: +{ options, config, lib, pkgs, ... }: with lib; with import ../../lib/qemu-flags.nix { inherit pkgs; }; { - # This option is a dummy that if used in conjunction with - # modules/virtualisation/qemu-vm.nix gets merged with the same option defined - # there and only is declared here because some modules use - # test-instrumentation.nix but not qemu-vm.nix. - # - # One particular example are the boot tests where we want instrumentation - # within the images but not other stuff like setting up 9p filesystems. - options.virtualisation.qemu = { }; - config = { systemd.services.backdoor = -- cgit 1.4.1