Skip to content
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

nixos/binfmt: handle emulatedSystems #61257

Merged
merged 3 commits into from May 12, 2019

Conversation

matthewbauer
Copy link
Member

Fixes #61248

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@Synthetica9
Copy link
Member

I'm not 100% sure how this would work, how are the interpreters specified?

@matthewbauer
Copy link
Member Author

I'm not 100% sure how this would work, how are the interpreters specified?

The interpreter comes from hostPlatform.emulator, which is used for a few build systems that need a native interpreter:

https://github.com/NixOS/nixpkgs/pull/58504/files#diff-036410e9211b4336186fc613f7200b12R6372

defined in

emulator = pkgs: let
qemu-user = pkgs.qemu.override {
smartcardSupport = false;
spiceSupport = false;
openGLSupport = false;
virglSupport = false;
vncSupport = false;
gtkSupport = false;
sdlSupport = false;
pulseSupport = false;
smbdSupport = false;
seccompSupport = false;
hostCpuTargets = ["${final.qemuArch}-linux-user"];
};
wine-name = "wine${toString final.parsed.cpu.bits}";
wine = (pkgs.winePackagesFor wine-name).minimal;
in
if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
pkgs.stdenv.hostPlatform.isCompatible final
then "${pkgs.runtimeShell} -c '\"$@\"' --"
else if final.isWindows
then "${wine}/bin/${wine-name}"
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux
then "${qemu-user}/bin/qemu-${final.qemuArch}"
else if final.isWasi
then "${pkgs.wasmtime}/bin/wasmtime"
else throw "Don't know how to run ${final.config} executables.";

@matthewbauer
Copy link
Member Author

I can build some armv7l-linux binaries with:

boot.binfmt.emulatedSystems = [ "armv7l-linux" ];

and

nix-build '<nixpkgs>' -A hello --argstr system armv7l-linux

@Ericson2314 Ericson2314 merged commit 395bcc0 into NixOS:master May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Provide QEMU presets for binfmtMiscRegistrations
3 participants