cleverca22
2/4/2016 - 10:54 AM

qemu userland

qemu userland

{ stdenv, fetchurl, python, pkgconfig, zlib, glib, user_arch, flex, bison, makeStaticLibraries }:

let
  env2 = makeStaticLibraries stdenv;
  myzlib = zlib.overrideDerivation (args: {
    configureFlags = toString args.configureFlags or "" + " --static";
  });
  myglib = glib.override { stdenv = env2; };
in
stdenv.mkDerivation rec {
  name = "qemu-user-${user_arch}-${version}";
  version = "2.4.0";
  buildInputs = [ python pkgconfig myzlib myglib flex bison ];
  src = fetchurl {
    url = "http://wiki.qemu.org/download/qemu-${version}.tar.bz2";
    sha256 = "0836gqv5zcl0xswwjcns3mlkn18lyz2fiq8rl1ihcm6cpf8vkc3j";
  };
  configureFlags = [
    "--enable-linux-user" "--target-list=${user_arch}-linux-user"
    "--disable-bsd-user" "--disable-system" "--disable-vnc" "--without-pixman"
    "--disable-vnc-tls" "--disable-curses" "--disable-sdl" "--disable-vde"
    "--disable-bluez" "--disable-kvm"
    "--static"
    "--disable-tools"
  ];
  postInstall = ''
    cat <<EOF > $out/bin/register
    #!/bin/sh
    modprobe binfmt_misc
    mount -t binfmt_misc binfmt_misc  /proc/sys/fs/binfmt_misc
    echo   ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff:$out/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
    EOF
    chmod +x $out/bin/register
  '';
}
diff -ru nix-1.11.1-orig/src/libstore/build.cc nix-1.11.1/src/libstore/build.cc
--- nix-1.11.1-orig/src/libstore/build.cc       2016-02-18 16:11:21.372535034 -0400
+++ nix-1.11.1/src/libstore/build.cc    2016-02-18 16:11:44.866337212 -0400
@@ -1259,16 +1259,7 @@
 
 static bool canBuildLocally(const BasicDerivation & drv)
 {
-    return drv.platform == settings.thisSystem
-        || isBuiltin(drv)
-#if __linux__
-        || (drv.platform == "i686-linux" && settings.thisSystem == "x86_64-linux")
-        || (drv.platform == "armv6l-linux" && settings.thisSystem == "armv7l-linux")
-#elif __FreeBSD__
-        || (drv.platform == "i686-linux" && settings.thisSystem == "x86_64-freebsd")
-        || (drv.platform == "i686-linux" && settings.thisSystem == "i686-freebsd")
-#endif
-        ;
+    return true;
 }
 
 

{
  packageOverrides = pkgs: rec {
    qemu-user-arm = pkgs.callPackage ./qemu-user.nix { user_arch = "arm"; };
    qemu-user-arm64 = pkgs.callPackage ./qemu-user.nix { user_arch = "aarch64"; };
    nix = pkgs.stdenv.lib.overrideDerivation pkgs.nix (oldAttrs: {
      patches = ./hax.patch;
    });
  };
}