-
-
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
Add documentation for emulators feature in cross infra #106375
Comments
@matthewbauer could you describe a bit how emulators works, how to use it, and how to run the nixpkgs tests? |
The emulators property of {build,host,target}Platform provides a way to run binaries for one architecture on another. It selects from a package set some emulator that's known to provide this in Nixpkgs. For example:
Emulators includes Wine, Qemu-user, & wasmtime, but the idea is to avoid specifying exactly which architecture you need. More examples:
|
I see that there are emulator tests in Nixpkgs, how would one run them? |
I tried a simple expression, but { pkgs ? import <nixpkgs> { }}:
with pkgs;
let
mingw-hello = pkgsCross.mingw32.hello;
emul = pkgsCross.mingw32.stdenv.hostPlatform.emulator pkgs;
in
rec {
runit = writeScript "runit" ''
#!/usr/bin/env sh
${emul} ${mingw-hello}/bin/hello
'';
} This worked, however { pkgs ? import <nixpkgs> { }}:
with pkgs;
let
hello-cross = pkgsCross.aarch64-multiplatform.hello;
emul = pkgsCross.aarch64-multiplatform.stdenv.hostPlatform.emulator pkgs;
in
rec {
runit = writeScript "runit" ''
#!/usr/bin/env sh
${emul} ${hello-cross}/bin/hello
'';
} |
@matthewbauer what kinds of things would this allow in Nixpkgs? There's several instances where packages use their own build artifacts as part of the build process, which wouldn't work when cross-compiling, so could we patch them to use the emulator to complete cross-compilation? |
I marked this as stale due to inactivity. → More info |
Still WIP |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/call-for-participation-nix-workshop-at-vandyhacks/15401/4 |
I think there are still two pieces missing here, but once they are added this will be quite a powerful feature:
I implemented (1) for one specific case (mips64el) here. The result is pretty nifty: you can use 9pfs to mount the host's This will be really handy for cross compilation situations where you have a long dependency chain of packages and all but one of them (buried somewhere in the middle of the chain) is able to cross-compile. For example, #166199. It would mean that an overlay could be used to swap out |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/stdenv-hostplatform-emulator-use-case/35367/1 |
While working on cross-related PRs I came across emulators introduced by 9c8fd41. They seem useful but haven't been documented anywhere. IMO would be a good addition to the cross-compilation section of the manual once #105364 is merged.
As I understand it, some use cases include
Pinging (author of emulators feature) @matthewbauer, (cross infra maintainer) @Ericson2314
The text was updated successfully, but these errors were encountered: