diff --git a/nixos/lib/qemu-common.nix b/nixos/lib/qemu-common.nix index 4fff2e0a6f15..b946f62d93dc 100644 --- a/nixos/lib/qemu-common.nix +++ b/nixos/lib/qemu-common.nix @@ -40,6 +40,7 @@ rec { otherHostGuestMatrix = { aarch64-darwin = { aarch64-linux = "${qemuPkg}/bin/qemu-system-aarch64 -machine virt,gic-version=2,accel=hvf:tcg -cpu max"; + inherit (otherHostGuestMatrix.x86_64-darwin) x86_64-linux; }; x86_64-darwin = { x86_64-linux = "${qemuPkg}/bin/qemu-system-x86_64 -machine type=q35,accel=hvf:tcg -cpu max"; diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index e0004df6f6b2..e335656a994c 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -656,8 +656,8 @@ in package = mkOption { type = types.package; - default = hostPkgs.qemu_kvm; - defaultText = literalExpression "config.virtualisation.host.pkgs.qemu_kvm"; + default = if hostPkgs.stdenv.hostPlatform.qemuArch == pkgs.stdenv.hostPlatform.qemuArch then hostPkgs.qemu_kvm else hostPkgs.qemu; + defaultText = literalExpression "if hostPkgs.stdenv.hostPlatform.qemuArch == pkgs.stdenv.hostPlatform.qemuArch then config.virtualisation.host.pkgs.qemu_kvm else config.virtualisation.host.pkgs.qemu"; example = literalExpression "pkgs.qemu_test"; description = lib.mdDoc "QEMU package to use."; }; diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index ed049340332c..bc35b2065697 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -233,15 +233,25 @@ impure-cmds // appleSourcePackages // chooseLibs // { ../../nixos/modules/profiles/macos-builder.nix ] ++ modules; + # If you need to override this, consider starting with the right Nixpkgs + # in the first place, ie change `pkgs` in `pkgs.darwin.linux-builder`. + # or if you're creating new wiring that's not `pkgs`-centric, perhaps use the + # macos-builder profile directly. virtualisation.host = { inherit pkgs; }; + + nixpkgs.hostPlatform = lib.mkDefault (toGuest stdenv.hostPlatform.system); }; - system = toGuest stdenv.hostPlatform.system; + system = null; }; in nixos.config.system.build.macos-builder-installer) { modules = [ ]; }; + linux-builder-x86_64 = self.linux-builder.override { + modules = [ { nixpkgs.hostPlatform = "x86_64-linux"; } ]; + }; + } // lib.optionalAttrs config.allowAliases { builder = throw "'darwin.builder' has been changed and renamed to 'darwin.linux-builder'. The default ssh port is now 31022. Please update your configuration or override the port back to 22. See https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder"; # added 2023-07-06 });