From 9f33ab62d99c98e3f5bddd64532f15f482cf01b2 Mon Sep 17 00:00:00 2001 From: Janne Heß Date: Tue, 2 Jun 2020 16:27:07 +0200 Subject: nixos/testing: Add support for specialArgs Since using flakes disallows the usage of (which I use in some tests), this adds an alternative. By setting specialArgs, all VMs can get the `unstable` flake input as an arg. This is not possible with extraConfigurations, as that would lead to infinite recursions. --- nixos/lib/build-vms.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nixos/lib/build-vms.nix') diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index 1bad63b9194..b1575fc13bb 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -3,8 +3,10 @@ minimal ? false , # Ignored config ? null - # Nixpkgs, for qemu, lib and more -, pkgs +, # Nixpkgs, for qemu, lib and more + pkgs +, # !!! See comment about args in lib/modules.nix + specialArgs ? {} , # NixOS configuration to add to the VMs extraConfigurations ? [] }: @@ -31,7 +33,7 @@ rec { nodes: configurations: import ./eval-config.nix { - inherit system; + inherit system specialArgs; modules = configurations ++ extraConfigurations; baseModules = (import ../modules/module-list.nix) ++ [ ../modules/virtualisation/qemu-vm.nix -- cgit 1.4.1 From bc2188b083dfbbe749a221023e2960b60d4c8951 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 21 Oct 2020 13:02:09 +0200 Subject: nixos: fix qemu_test being used in normal VMs This is an attempt to fixup PR #49403. --- nixos/lib/build-vms.nix | 4 ---- nixos/modules/testing/test-instrumentation.nix | 5 ++++- nixos/modules/virtualisation/qemu-vm.nix | 11 ++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'nixos/lib/build-vms.nix') diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index b1575fc13bb..ebbb0296bef 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -18,9 +18,6 @@ rec { inherit pkgs; - qemu = pkgs.qemu_test; - - # Build a virtual network from an attribute set `{ machine1 = # config1; ... machineN = configN; }', where `machineX' is the # hostname and `configX' is a NixOS system configuration. Each @@ -39,7 +36,6 @@ rec { [ ../modules/virtualisation/qemu-vm.nix ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs { key = "no-manual"; documentation.nixos.enable = false; } - { key = "qemu"; system.build.qemu = qemu; } { key = "nodes"; _module.args.nodes = nodes; } ] ++ optional minimal ../modules/testing/minimal-kernel.nix; }; diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index dbbcb0bed5b..e9f5eac7f5f 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -51,7 +51,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; # 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 ]; }; + virtualisation.qemu = { + consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice; + package = pkgs.qemu_test; + }; boot.initrd.preDeviceCommands = '' diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 42e43f5ee02..191d7c758c0 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -14,10 +14,11 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; let - qemu = config.system.build.qemu or pkgs.qemu_test; cfg = config.virtualisation; + qemu = cfg.qemu.package; + consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles; driveOpts = { ... }: { @@ -401,6 +402,14 @@ in }; virtualisation.qemu = { + package = + mkOption { + type = types.package; + default = pkgs.qemu; + example = "pkgs.qemu_test"; + description = "QEMU package to use."; + }; + options = mkOption { type = types.listOf types.unspecified; -- cgit 1.4.1 From 169c6b4b1478a3a0c823c99ea39d4082f76a2708 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 22 Mar 2021 21:37:54 +0100 Subject: nixosTest: Make system.nixos.revision constant Make the revision metadata constant, in order to avoid needless retesting. The human version (e.g. 21.05-pre) is left as is, because it is useful for external modules that test with e.g. nixosTest and rely on that version number. --- nixos/lib/build-vms.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nixos/lib/build-vms.nix') diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index ebbb0296bef..064e44f643b 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -36,6 +36,13 @@ rec { [ ../modules/virtualisation/qemu-vm.nix ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs { key = "no-manual"; documentation.nixos.enable = false; } + { key = "no-revision"; + # Make the revision metadata constant, in order to avoid needless retesting. + # The human version (e.g. 21.05-pre) is left as is, because it is useful + # for external modules that test with e.g. nixosTest and rely on that + # version number. + config.system.nixos.revision = "constant-nixos-revision"; + } { key = "nodes"; _module.args.nodes = nodes; } ] ++ optional minimal ../modules/testing/minimal-kernel.nix; }; -- cgit 1.4.1 From 8bbdff45816c657f679cd77c0a0dbca534a85bf3 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sun, 20 Jun 2021 23:29:26 -0500 Subject: nixosTest: Force system.nixos.revision constant nixos tests are blended with other system configurations, hence their settings must be either enforced or defaulted. This particular setting is set via lib.nixosSystem as `system.nixos.revision = final.mkIf (self ? rev) self.rev;` which would mean that without this change no flake generated nixos could be blended with nixos testing. This setting was made previously constant in 169c6b4b1478a3a0c823c99ea39d4082f76a2708 in order to avoid pointless rebuilds of the testing VMs, but was set without enforcing it. --- nixos/lib/build-vms.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/lib/build-vms.nix') diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index 064e44f643b..f0a58628c68 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -41,7 +41,7 @@ rec { # The human version (e.g. 21.05-pre) is left as is, because it is useful # for external modules that test with e.g. nixosTest and rely on that # version number. - config.system.nixos.revision = "constant-nixos-revision"; + config.system.nixos.revision = mkForce "constant-nixos-revision"; } { key = "nodes"; _module.args.nodes = nodes; } ] ++ optional minimal ../modules/testing/minimal-kernel.nix; -- cgit 1.4.1