-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runInLinuxVM: add hostPkgs
#352946
base: master
Are you sure you want to change the base?
runInLinuxVM: add hostPkgs
#352946
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
{ lib | ||
|
||
# pkgs used inside the VM | ||
, pkgs | ||
|
||
# pkgs used outside the VM | ||
# (similar to NixOS's `virtualisation.host.pkgs` option) | ||
# using over `buildPackages` as currently `nix-build -E '(import <nixpkgs> { }).pkgsCross.aarch64-multiplatform.buildPackages.qemu_kvm'` | ||
# fails on aarch64-darwin with `error: Don't know how to run aarch64-unknown-linux-gnu executables.` | ||
, hostPkgs ? pkgs.buildPackages | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overall there are 4 packages which need to comre from
|
||
, customQemu ? null | ||
, kernel ? pkgs.linux | ||
, img ? pkgs.stdenv.hostPlatform.linux-kernel.target | ||
|
@@ -12,12 +21,15 @@ | |
let | ||
inherit (pkgs) bash bashInteractive busybox cpio coreutils e2fsprogs fetchurl kmod rpm | ||
stdenv util-linux | ||
buildPackages writeScript writeText runCommand; | ||
buildPackages writeScript runCommand; | ||
in | ||
rec { | ||
qemu-common = import ../../../nixos/lib/qemu-common.nix { inherit lib pkgs; }; | ||
|
||
qemu = buildPackages.qemu_kvm; | ||
qemu = hostPkgs.qemu_kvm; | ||
|
||
# export hostPkgs so that downstream tools that wrap around e.g. runInLinuxVM can use it | ||
inherit hostPkgs; | ||
|
||
modulesClosure = pkgs.makeModulesClosure { | ||
inherit kernel rootModules; | ||
|
@@ -232,10 +244,10 @@ rec { | |
''; | ||
|
||
|
||
vmRunCommand = qemuCommand: writeText "vm-run" '' | ||
vmRunCommand = qemuCommand: hostPkgs.writeText "vm-run" '' | ||
export > saved-env | ||
|
||
PATH=${coreutils}/bin | ||
PATH=${hostPkgs.coreutils}/bin | ||
mkdir xchg | ||
mv saved-env xchg/ | ||
|
||
|
@@ -253,7 +265,7 @@ rec { | |
# debug inside the VM if the build fails (when Nix is called with | ||
# the -K option to preserve the temporary build directory). | ||
cat > ./run-vm <<EOF | ||
#! ${bash}/bin/sh | ||
#! ${hostPkgs.bash}/bin/sh | ||
''${diskImage:+diskImage=$diskImage} | ||
TMPDIR=$TMPDIR | ||
cd $TMPDIR | ||
|
@@ -334,8 +346,9 @@ rec { | |
that allows you to boot into the VM and debug it interactively. */ | ||
|
||
runInLinuxVM = drv: lib.overrideDerivation drv ({ memSize ? 512, QEMU_OPTS ? "", args, builder, ... }: { | ||
requiredSystemFeatures = [ "kvm" ]; | ||
builder = "${bash}/bin/sh"; | ||
system = hostPkgs.system; | ||
requiredSystemFeatures = if !hostPkgs.stdenv.isDarwin then [ "kvm" ] else []; | ||
builder = "${hostPkgs.bash}/bin/sh"; | ||
args = ["-e" (vmRunCommand qemuCommandLinux)]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing |
||
origArgs = args; | ||
origBuilder = builder; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no
qemu-user
for darwinnixpkgs/lib/systems/default.nix
Lines 289 to 290 in 068b0aa
Package ‘qemu-user-9.1.1’ in ./pkgs/applications/virtualization/qemu/default.nix:318 is not available on the requested hostPlatform
which we need for cross-compiling
gobject-introspection
Maybe a conditional wrong somewhere
I think we need to improve the conditional for this or shift offsets in the python withPackages tree (if they're wrong)
nixpkgs/pkgs/development/libraries/graphene/default.nix
Lines 97 to 98 in b084db8
There's
++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "installedTests" ];
above so for the installed test stuff we probably need that conditional tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#353237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, @Artturin thank you so much! What wizardry is that 😄 On your branch I can evaluate
qemu_kvm
but the build fails. I'm investigating that.