From 9d6ee212624c7b6a331945f49c4c7afc86bd26e2 Mon Sep 17 00:00:00 2001 From: Philip Taron Date: Wed, 17 Dec 2025 14:50:21 -0800 Subject: [PATCH] nixos: pass stdenv into qemu-common We also don't export it from `vmTools` anymore. --- nixos/lib/qemu-common.nix | 10 +++++----- nixos/lib/testing/network.nix | 2 +- nixos/modules/testing/test-instrumentation.nix | 2 +- nixos/modules/virtualisation/qemu-vm.nix | 2 +- nixos/tests/boot.nix | 2 +- nixos/tests/networking/router.nix | 2 +- pkgs/build-support/vm/default.nix | 5 +---- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/lib/qemu-common.nix b/nixos/lib/qemu-common.nix index 5629b0b81d20..a43b624cdbce 100644 --- a/nixos/lib/qemu-common.nix +++ b/nixos/lib/qemu-common.nix @@ -1,5 +1,5 @@ # QEMU-related utilities shared between various Nix expressions. -{ lib, pkgs }: +{ lib, stdenv }: let zeroPad = @@ -17,19 +17,19 @@ rec { ]; qemuSerialDevice = - if with pkgs.stdenv.hostPlatform; isx86 || isLoongArch64 || isMips64 || isRiscV then + if with stdenv.hostPlatform; isx86 || isLoongArch64 || isMips64 || isRiscV then "ttyS0" - else if (with pkgs.stdenv.hostPlatform; isAarch || isPower) then + else if (with stdenv.hostPlatform; isAarch || isPower) then "ttyAMA0" else - throw "Unknown QEMU serial device for system '${pkgs.stdenv.hostPlatform.system}'"; + throw "Unknown QEMU serial device for system '${stdenv.hostPlatform.system}'"; qemuBinary = qemuPkg: let hostStdenv = qemuPkg.stdenv; hostSystem = hostStdenv.system; - guestSystem = pkgs.stdenv.hostPlatform.system; + guestSystem = stdenv.hostPlatform.system; linuxHostGuestMatrix = { x86_64-linux = "${qemuPkg}/bin/qemu-system-x86_64 -machine accel=kvm:tcg -cpu max"; diff --git a/nixos/lib/testing/network.nix b/nixos/lib/testing/network.nix index 1188e9bec505..e65767e7fb99 100644 --- a/nixos/lib/testing/network.nix +++ b/nixos/lib/testing/network.nix @@ -30,7 +30,7 @@ let ... }: let - qemu-common = import ../qemu-common.nix { inherit lib pkgs; }; + qemu-common = import ../qemu-common.nix { inherit (pkgs) lib stdenv; }; # Convert legacy VLANs to named interfaces and merge with explicit interfaces. vlansNumbered = forEach (zipLists config.virtualisation.vlans (range 1 255)) (v: { diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 3ec4fdc0e2a0..dce59a0a93b7 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -14,7 +14,7 @@ with lib; let cfg = config.testing; - qemu-common = import ../../lib/qemu-common.nix { inherit lib pkgs; }; + qemu-common = import ../../lib/qemu-common.nix { inherit (pkgs) lib stdenv; }; backdoorService = { requires = [ diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index abded7525062..8a6c55cfc9fa 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -16,7 +16,7 @@ with lib; let - qemu-common = import ../../lib/qemu-common.nix { inherit lib pkgs; }; + qemu-common = import ../../lib/qemu-common.nix { inherit (pkgs) lib stdenv; }; cfg = config.virtualisation; diff --git a/nixos/tests/boot.nix b/nixos/tests/boot.nix index 863d80e41dac..d1ac1a8769fe 100644 --- a/nixos/tests/boot.nix +++ b/nixos/tests/boot.nix @@ -8,7 +8,7 @@ with import ../lib/testing-python.nix { inherit system pkgs; }; let lib = pkgs.lib; - qemu-common = import ../lib/qemu-common.nix { inherit lib pkgs; }; + qemu-common = import ../lib/qemu-common.nix { inherit (pkgs) lib stdenv; }; mkStartCommand = { diff --git a/nixos/tests/networking/router.nix b/nixos/tests/networking/router.nix index 082f2bc7d227..ae9c64607a66 100644 --- a/nixos/tests/networking/router.nix +++ b/nixos/tests/networking/router.nix @@ -2,7 +2,7 @@ { config, pkgs, ... }: let inherit (pkgs) lib; - qemu-common = import ../../lib/qemu-common.nix { inherit lib pkgs; }; + qemu-common = import ../../lib/qemu-common.nix { inherit (pkgs) lib stdenv; }; vlanIfs = lib.range 1 (lib.length config.virtualisation.vlans); in { diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 0741ed1410cc..de0b589a37e6 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -24,7 +24,6 @@ writeText, xz, zstd, - pkgs, # ---------------------------- # The following arguments form the "interface" of `pkgs.vmTools`. @@ -47,7 +46,7 @@ }: let - qemu-common = import ../../../nixos/lib/qemu-common.nix { inherit lib pkgs; }; + qemu-common = import ../../../nixos/lib/qemu-common.nix { inherit lib stdenv; }; qemu = buildPackages.qemu_kvm; @@ -1323,8 +1322,6 @@ in makeImageTestScript modulesClosure qemu - qemu-common - qemuCommandLinux rpmClosureGenerator rpmDistros runInLinuxImage