@@ -45,15 +45,21 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
4545 systemd.services."serial-getty@${qemuSerialDevice}".enable = false;
4646 systemd.services."serial-getty@hvc0".enable = false;
4747
48− # Only use a serial console, no TTY.
49− # NOTE: optionalAttrs
50− # test-instrumentation.nix appears to be used without qemu-vm.nix, so
51− # we avoid defining consoles if not possible.
52− # TODO: refactor such that test-instrumentation can import qemu-vm
53− # or declare virtualisation.qemu.console option in a module that's always imported
54− virtualisation.qemu = {
55− consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice;
56− package = lib.mkDefault pkgs.qemu_test;
48+ # Only set these settings when the options exist. Some tests (e.g. those
49+ # that do not specify any nodes, or an empty attr set as nodes) will not
50+ # have the QEMU module loaded and thuse these options can't and should not
51+ # be set.
52+ virtualisation = lib.optionalAttrs (options ? virtualisation.qemu) {
53+ qemu = {
54+ # Only use a serial console, no TTY.
55+ # NOTE: optionalAttrs
56+ # test-instrumentation.nix appears to be used without qemu-vm.nix, so
57+ # we avoid defining consoles if not possible.
58+ # TODO: refactor such that test-instrumentation can import qemu-vm
59+ # or declare virtualisation.qemu.console option in a module that's always imported
60+ consoles = [ qemuSerialDevice ];
61+ package = lib.mkDefault pkgs.qemu_test;
62+ };
5763 };
5864
5965 boot.initrd.preDeviceCommands =