diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2018-11-13 16:54:08 -0600 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2018-11-29 19:15:30 -0600 |
commit | 9c8fd412248ad907eee7547b19bf3f7583d2c411 (patch) | |
tree | 0db9bedd232a22f0c17c4d7c9f101d9ddaeed160 /lib/systems/default.nix | |
parent | ce6d558c4deebf373eae8723cfb7c181be2be9be (diff) | |
download | nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.tar nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.tar.gz nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.tar.bz2 nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.tar.lz nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.tar.xz nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.tar.zst nixpkgs-9c8fd412248ad907eee7547b19bf3f7583d2c411.zip |
treewide: add emulator to platform
You can use stdenv.hostPlatform.emulator to get an executable that runs cross-built binaries. This could be any emulator. For instance, we use QEMU to emulate Linux targets and Wine to emulate Windows targets. To work with qemu, we need to support custom targets. I’ve reworked the cross tests in pkgs/test/cross to use this functionality. Also, I’ve used talloc to cross-execute with the emulator. There appears to be a cross-execute for all waf builds. In the future, it would be nice to set this for all waf builds. Adds stdenv.hostPlatform.qemuArch attrbute to get the qemuArch for each platform.
Diffstat (limited to 'lib/systems/default.nix')
-rw-r--r-- | lib/systems/default.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 0b3475fefb9..25df5e17406 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -66,6 +66,46 @@ rec { # uname -r release = null; }; + + qemuArch = + if final.isArm then "arm" + else if final.isx86_64 then "x86_64" + else if final.isx86 then "i386" + else { + "powerpc" = "ppc"; + "powerpc64" = "ppc64"; + "powerpc64le" = "ppc64"; + "mips64" = "mips"; + "mipsel64" = "mipsel"; + }.${final.parsed.cpu.name} or final.parsed.cpu.name; + + 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 && + (final.parsed.cpu.name == pkgs.stdenv.hostPlatform.parsed.cpu.name || + (final.platform.isi686 && pkgs.stdenv.hostPlatform.isx86_64)) + then pkgs.runtimeShell + 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 throw "Don't know how to run ${final.config} executables."; + } // mapAttrs (n: v: v final.parsed) inspect.predicates // args; in assert final.useAndroidPrebuilt -> final.isAndroid; |