about summary refs log tree commit diff
path: root/pkgs/stdenv/linux
diff options
context:
space:
mode:
authorviric <viric@viric.name>2015-02-05 22:35:31 +0100
committerviric <viric@viric.name>2015-02-05 22:35:31 +0100
commit4b9729f9d9eea4feb751565370a3dd1d4197f88f (patch)
tree7ffca3974ce262d05313c8d25772656222df920d /pkgs/stdenv/linux
parentdee90b2c251aebb4557f1d0fb55c40cf67e85381 (diff)
parentef9c21a0e27974aabf6bad1b04d53922a6566ff5 (diff)
downloadnixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.tar
nixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.tar.gz
nixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.tar.bz2
nixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.tar.lz
nixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.tar.xz
nixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.tar.zst
nixlib-4b9729f9d9eea4feb751565370a3dd1d4197f88f.zip
Merge pull request #6184 from ambrop72/bootstrap-tools-staging
Bootstrap tools improvements to cross-compile for ARM
Diffstat (limited to 'pkgs/stdenv/linux')
-rw-r--r--pkgs/stdenv/linux/bootstrap/armv6l.nix17
-rw-r--r--pkgs/stdenv/linux/bootstrap/armv7l.nix12
-rw-r--r--pkgs/stdenv/linux/default.nix64
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix198
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix94
-rw-r--r--pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh56
-rw-r--r--pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh4
7 files changed, 177 insertions, 268 deletions
diff --git a/pkgs/stdenv/linux/bootstrap/armv6l.nix b/pkgs/stdenv/linux/bootstrap/armv6l.nix
index 85b868359052..34429413e73d 100644
--- a/pkgs/stdenv/linux/bootstrap/armv6l.nix
+++ b/pkgs/stdenv/linux/bootstrap/armv6l.nix
@@ -1,11 +1,12 @@
-# Use the static tools for armv5tel-linux.
-(import ./armv5tel.nix) //
-
 {
-  bootstrapTools = {
-    # Built from make-bootstrap-tools-crosspi.nix
-    # nixpkgs rev eb0422e4c1263a65a9b2b954fe10a1e03d67db3e
-    url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2;
-    sha256 = "1zb27x5h54k51yrvn3sy4wb1qprx8iv2kfbgklxwc0mcxp9b7ccd";
+  busybox = import <nix/fetchurl.nix> {
+    url = https://dl.dropboxusercontent.com/s/4705ffxjrxxqnh2/busybox?dl=0;
+    sha256 = "032maafy4akcdgccpxdxrza29pkcpm81g8kh1hv8bj2rvssly3z2";
+    executable = true;
+  };
+
+  bootstrapTools = import <nix/fetchurl.nix> {
+    url = https://dl.dropboxusercontent.com/s/pen8ieymeqqdvqn/bootstrap-tools.tar.xz?dl=0;
+    sha256 = "0kjpjwi6qw82ca02ppsih3bnhc3y150q23k9d56xzscs0xf5d0dv";
   };
 }
diff --git a/pkgs/stdenv/linux/bootstrap/armv7l.nix b/pkgs/stdenv/linux/bootstrap/armv7l.nix
new file mode 100644
index 000000000000..a6225f455de9
--- /dev/null
+++ b/pkgs/stdenv/linux/bootstrap/armv7l.nix
@@ -0,0 +1,12 @@
+{
+  busybox = import <nix/fetchurl.nix> {
+    url = https://dl.dropboxusercontent.com/s/rowzme529tc5svq/busybox?dl=0;
+    sha256 = "18793riwv9r1bgz6zv03c84cd0v26gxsm8wd2c7gjrwwyfg46ls4";
+    executable = true;
+  };
+
+  bootstrapTools = import <nix/fetchurl.nix> {
+    url = https://dl.dropboxusercontent.com/s/3jr4s5449t7zjlj/bootstrap-tools.tar.xz?dl=0;
+    sha256 = "1qyp871dajz5mi3yaw9sndwh4yrh1jj184wjjwaf6dpr3jir4kyd";
+  };
+}
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index e82338450688..1876a8957e9a 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -7,16 +7,18 @@
 # The function defaults are for easy testing.
 { system ? builtins.currentSystem
 , allPackages ? import ../../top-level/all-packages.nix
-, platform ? null, config ? {}, lib ? (import ../../../lib) }:
+, platform ? null, config ? {}, lib ? (import ../../../lib)
+, customBootstrapFiles ? null }:
 
 rec {
 
   bootstrapFiles =
-    if system == "i686-linux" then import ./bootstrap/i686.nix
+    if customBootstrapFiles != null then customBootstrapFiles
+    else if system == "i686-linux" then import ./bootstrap/i686.nix
     else if system == "x86_64-linux" then import ./bootstrap/x86_64.nix
     else if system == "armv5tel-linux" then import ./bootstrap/armv5tel.nix
     else if system == "armv6l-linux" then import ./bootstrap/armv6l.nix
-    else if system == "armv7l-linux" then import ./bootstrap/armv6l.nix
+    else if system == "armv7l-linux" then import ./bootstrap/armv7l.nix
     else if system == "mips64el-linux" then import ./bootstrap/loongson2f.nix
     else abort "unsupported platform for the pure Linux stdenv";
 
@@ -42,11 +44,7 @@ rec {
 
     builder = bootstrapFiles.busybox;
 
-    args =
-      if system == "armv5tel-linux" || system == "armv6l-linux"
-        || system == "armv7l-linux"
-      then [ ./scripts/unpack-bootstrap-tools-arm.sh ]
-      else [ "ash" "-e" ./scripts/unpack-bootstrap-tools.sh ];
+    args = [ "ash" "-e" ./scripts/unpack-bootstrap-tools.sh ];
 
     tarball = bootstrapFiles.bootstrapTools;
 
@@ -297,5 +295,53 @@ rec {
         attr acl paxctl zlib pcre;
     };
   };
-
+  
+  
+  testBootstrapTools = let
+    defaultPkgs = allPackages { inherit system platform; };
+  in derivation {
+    name = "test-bootstrap-tools";
+    inherit system;
+    builder = bootstrapFiles.busybox;
+    args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
+
+    buildCommand = ''
+      export PATH=${bootstrapTools}/bin
+      
+      ls -l
+      mkdir $out
+      mkdir $out/bin
+      sed --version
+      find --version
+      diff --version
+      patch --version
+      make --version
+      awk --version
+      grep --version
+      gcc --version
+      curl --version
+
+      ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
+      export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
+      export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
+      export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
+
+      echo '#include <stdio.h>' >> foo.c
+      echo '#include <limits.h>' >> foo.c
+      echo 'int main() { printf("Hello World\\n"); return 0; }' >> foo.c
+      $CC -o $out/bin/foo foo.c
+      $out/bin/foo
+
+      echo '#include <iostream>' >> bar.cc
+      echo 'int main() { std::cout << "Hello World\\n"; }' >> bar.cc
+      $CXX -v -o $out/bin/bar bar.cc
+      $out/bin/bar
+
+      tar xvf ${defaultPkgs.hello.src}
+      cd hello-*
+      ./configure --prefix=$out
+      make
+      make install
+    '';
+  };
 }
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix
index 1d2919919b1e..013aa12d9564 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix
@@ -1,10 +1,26 @@
 {system ? builtins.currentSystem}:
 
+let buildFor = toolsArch: (
+
 let
   pkgsFun = import ../../top-level/all-packages.nix;
   pkgsNoParams = pkgsFun {};
+  
+  sheevaplugCrossSystem = {
+    crossSystem = rec {
+      config = "armv5tel-unknown-linux-gnueabi";
+      bigEndian = false;
+      arch = "arm";
+      float = "soft";
+      withTLS = true;
+      libc = "glibc";
+      platform = pkgsNoParams.platforms.sheevaplug;
+      openssl.system = "linux-generic32";
+    };
+  };
+  
   raspberrypiCrossSystem = {
-    crossSystem = {
+    crossSystem = rec {
       config = "armv6l-unknown-linux-gnueabi";  
       bigEndian = false;
       arch = "arm";
@@ -14,51 +30,34 @@ let
       libc = "glibc";
       platform = pkgsNoParams.platforms.raspberrypi;
       openssl.system = "linux-generic32";
-      gcc = {
-        arch = "armv6";
-        fpu = "vfp";
-        float = "hard";
-      };
+      inherit (platform) gcc;
     };
   };
-
-  raspberrypiCrossSystemUclibc = {
-    crossSystem = {
-      config = "armv6l-unknown-linux-gnueabi";  
+  
+  beagleboneCrossSystem = {
+    crossSystem = rec {
+      config = "armv7l-unknown-linux-gnueabi";  
       bigEndian = false;
       arch = "arm";
       float = "hard";
-      fpu = "vfp";
+      fpu = "vfpv3-d16";
       withTLS = true;
-      libc = "uclibc";
-      platform = pkgsNoParams.platforms.raspberrypi;
+      libc = "glibc";
+      platform = pkgsNoParams.platforms.beaglebone;
       openssl.system = "linux-generic32";
-      gcc = {
-        arch = "armv6";
-        fpu = "vfp";
-        float = "hard";
-      };
-      uclibc.extraConfig = ''
-        ARCH_WANTS_BIG_ENDIAN n
-        ARCH_BIG_ENDIAN n
-        ARCH_WANTS_LITTLE_ENDIAN y
-        ARCH_LITTLE_ENDIAN y
-      '';
+      inherit (platform) gcc;
     };
   };
+  
+  selectedCrossSystem =
+    if toolsArch == "armv5tel" then sheevaplugCrossSystem else
+    if toolsArch == "armv6l" then raspberrypiCrossSystem else
+    if toolsArch == "armv7l" then beagleboneCrossSystem else null;
 
-  pkgsuclibc = pkgsFun ({inherit system;} // raspberrypiCrossSystemUclibc);
-  pkgs = pkgsFun ({inherit system;} // raspberrypiCrossSystem);
+  pkgs = pkgsFun ({inherit system;} // selectedCrossSystem);
 
   inherit (pkgs) stdenv nukeReferences cpio binutilsCross;
 
-  # We want coreutils without ACL support.
-  coreutils_base = pkgs.coreutils.override (args: {
-    aclSupport = false;
-  });
-
-  coreutils_ = coreutils_base.crossDrv;
-
   glibc = pkgs.libcCross;
   bash = pkgs.bash.crossDrv;
   findutils = pkgs.findutils.crossDrv;
@@ -72,9 +71,8 @@ let
   gnumake = pkgs.gnumake.crossDrv;
   patch = pkgs.patch.crossDrv;
   patchelf = pkgs.patchelf.crossDrv;
-  replace = pkgs.replace.crossDrv;
-  gcc = pkgs.gcc;
-  gmp = pkgs.gmp.crossDrv;
+  gcc = pkgs.gcc.cc.crossDrv;
+  gmpxx = pkgs.gmpxx.crossDrv;
   mpfr = pkgs.mpfr.crossDrv;
   ppl = pkgs.ppl.crossDrv;
   cloogppl = pkgs.cloogppl.crossDrv;
@@ -83,26 +81,39 @@ let
   isl = pkgs.isl.crossDrv;
   libmpc = pkgs.libmpc.crossDrv;
   binutils = pkgs.binutils.crossDrv;
-  klibc = pkgs.linuxPackages.klibc.crossDrv;
+  libelf = pkgs.libelf.crossDrv;
 
 in
 
 rec {
 
-  curlStatic = import <nixpkgs/pkgs/tools/networking/curl> {
-    stdenv = pkgsuclibc.stdenv;
-    inherit (pkgsuclibc) fetchurl;
+  # We want coreutils without ACL support.
+  coreutilsMinimal = (pkgs.coreutils.override (args: {
+    aclSupport = false;
+  })).crossDrv;
+  
+  curlMinimal = (pkgs.curl.override {
     zlibSupport = false;
     sslSupport = false;
-    linkStatic = true;
-  };
-
-  bzip2Static = import <nixpkgs/pkgs/tools/compression/bzip2> {
-    stdenv = pkgsuclibc.stdenv;
-    inherit (pkgsuclibc) fetchurl;
-    linkStatic = true;
-  };
-
+    scpSupport = false;
+  }).crossDrv;
+  
+  busyboxMinimal = (pkgs.busybox.override {
+    # TBD: uClibc is broken.
+    # useUclibc = true;
+    enableStatic = true;
+    enableMinimal = true;
+    extraConfig = ''
+      CONFIG_ASH y
+      CONFIG_ASH_BUILTIN_ECHO y
+      CONFIG_ASH_BUILTIN_TEST y
+      CONFIG_ASH_OPTIMIZE_FOR_SIZE y
+      CONFIG_MKDIR y
+      CONFIG_TAR y
+      CONFIG_UNXZ y
+    '';
+  }).crossDrv;
+  
   inherit pkgs;
 
   build = 
@@ -128,6 +139,8 @@ rec {
         cp -d ${glibc}/lib/libpthread*.so* $out/lib
         cp -d ${glibc}/lib/libnsl*.so* $out/lib
         cp -d ${glibc}/lib/libutil*.so* $out/lib
+        cp -d ${glibc}/lib/libnss*.so* $out/lib
+        cp -d ${glibc}/lib/libresolv*.so* $out/lib
         cp -d ${glibc}/lib/crt?.o $out/lib
         
         cp -rL ${glibc}/include $out
@@ -140,7 +153,7 @@ rec {
         mv $out/include $out/include-glibc
         
         # Copy coreutils, bash, etc.
-        cp ${coreutils_}/bin/* $out/bin
+        cp ${coreutilsMinimal}/bin/* $out/bin
         (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users)
         
         cp ${bash}/bin/bash $out/bin
@@ -148,7 +161,7 @@ rec {
         cp ${findutils}/bin/xargs $out/bin
         cp -d ${diffutils}/bin/* $out/bin
         cp -d ${gnused}/bin/* $out/bin
-        cp -d ${gnugrep}/bin/* $out/bin
+        cp -d ${gnugrep}/bin/grep $out/bin
         cp ${gawk}/bin/gawk $out/bin
         cp -d ${gawk}/bin/awk $out/bin
         cp ${gnutar}/bin/tar $out/bin
@@ -157,17 +170,18 @@ rec {
         cp -d ${gnumake}/bin/* $out/bin
         cp -d ${patch}/bin/* $out/bin
         cp ${patchelf}/bin/* $out/bin
-        cp ${replace}/bin/* $out/bin
+        cp ${curlMinimal}/bin/curl $out/bin
+        cp -d ${curlMinimal}/lib/libcurl* $out/lib
 
         cp -d ${gnugrep.pcre.crossDrv}/lib/libpcre*.so* $out/lib # needed by grep
         
         # Copy what we need of GCC.
-        cp -d ${gcc.cc.crossDrv}/bin/gcc $out/bin
-        cp -d ${gcc.cc.crossDrv}/bin/cpp $out/bin
-        cp -d ${gcc.cc.crossDrv}/bin/g++ $out/bin
-        cp -d ${gcc.cc.crossDrv}/lib*/libgcc_s.so* $out/lib
-        cp -d ${gcc.cc.crossDrv}/lib*/libstdc++.so* $out/lib
-        cp -rd ${gcc.cc.crossDrv}/lib/gcc $out/lib
+        cp -d ${gcc}/bin/gcc $out/bin
+        cp -d ${gcc}/bin/cpp $out/bin
+        cp -d ${gcc}/bin/g++ $out/bin
+        cp -d ${gcc}/lib*/libgcc_s.so* $out/lib
+        cp -d ${gcc}/lib*/libstdc++.so* $out/lib
+        cp -rd ${gcc}/lib/gcc $out/lib
         chmod -R u+w $out/lib
         rm -f $out/lib/gcc/*/*/include*/linux
         rm -f $out/lib/gcc/*/*/include*/sound
@@ -175,26 +189,31 @@ rec {
         rm -f $out/lib/gcc/*/*/include-fixed/asm
         rm -rf $out/lib/gcc/*/*/plugin
         #rm -f $out/lib/gcc/*/*/*.a
-        cp -rd ${gcc.cc.crossDrv}/libexec/* $out/libexec
+        cp -rd ${gcc}/libexec/* $out/libexec
+        chmod -R u+w $out/libexec
+        rm -rf $out/libexec/gcc/*/*/plugin
         mkdir $out/include
-        cp -rd ${gcc.cc.crossDrv}/include/c++ $out/include
+        cp -rd ${gcc}/include/c++ $out/include
         chmod -R u+w $out/include
         rm -rf $out/include/c++/*/ext/pb_ds
         rm -rf $out/include/c++/*/ext/parallel
 
-        cp -d ${gmp}/lib/libgmp*.so* $out/lib
+        cp -d ${gmpxx}/lib/libgmp*.so* $out/lib
         cp -d ${mpfr}/lib/libmpfr*.so* $out/lib
+        cp -d ${libmpc}/lib/libmpc*.so* $out/lib
+        cp -d ${zlib}/lib/libz.so* $out/lib
+        cp -d ${libelf}/lib/libelf.so* $out/lib
+        
+        # TBD: Why are these needed for cross but not native tools?
         cp -d ${cloogppl}/lib/libcloog*.so* $out/lib
         cp -d ${cloog}/lib/libcloog*.so* $out/lib
-        cp -d ${ppl}/lib/libppl*.so* $out/lib
         cp -d ${isl}/lib/libisl*.so* $out/lib
-        cp -d ${libmpc}/lib/libmpc*.so* $out/lib
-        cp -d ${zlib}/lib/libz.so* $out/lib
         
         # Copy binutils.
         for i in as ld ar ranlib nm strip readelf objdump; do
           cp ${binutils}/bin/$i $out/bin
         done
+        cp -d ${binutils}/lib/lib*.so* $out/lib
 
         chmod -R u+w $out
         
@@ -209,26 +228,16 @@ rec {
         nuke-refs $out/bin/*
         nuke-refs $out/lib/*
         nuke-refs $out/libexec/gcc/*/*/*
-        nuke-refs $out/libexec/gcc/*/*/*/*
 
         mkdir $out/.pack
         mv $out/* $out/.pack
         mv $out/.pack $out/pack
 
         mkdir $out/on-server
-        (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2
-
-        mkdir $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/sh $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs
-        cp ${klibc}/lib/klibc/bin.static/ln $out/in-nixpkgs
-        cp ${curlStatic.crossDrv}/bin/curl $out/in-nixpkgs
-        cp ${bzip2Static.crossDrv}/bin/bzip2 $out/in-nixpkgs
-        chmod u+w $out/in-nixpkgs/*
-        $crossConfig-strip $out/in-nixpkgs/*
-        nuke-refs $out/in-nixpkgs/*
-        bzip2 $out/in-nixpkgs/curl
+        tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack .
+        cp ${busyboxMinimal}/bin/busybox $out/on-server
+        chmod u+w $out/on-server/busybox
+        nuke-refs $out/on-server/busybox
       ''; # */
 
       # The result should not contain any references (store paths) so
@@ -237,33 +246,10 @@ rec {
       allowedReferences = [];
     };
 
-  
-  unpack =
-    
-    stdenv.mkDerivation {
-      name = "unpack";
-
-      buildCommand = ''
-        ${build}/in-nixpkgs/mkdir $out
-        ${build}/in-nixpkgs/bzip2 -d < ${build}/on-server/bootstrap-tools.cpio.bz2 | (cd $out && ${build}/in-nixpkgs/cpio -V -i)
-
-        for i in $out/bin/* $out/libexec/gcc/*/*/*; do
-            echo patching $i
-            if ! test -L $i; then
-                LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \
-                    $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath $i
-            fi
-        done
-
-        # Fix the libc linker script.
-        for i in $out/lib/libc.so; do
-            cat $i | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $i.tmp
-            mv $i.tmp $i
-        done
-      ''; # " */
-
-      allowedReferences = ["out"];
-    };
+}
 
-    
+); in {
+    armv5tel = buildFor "armv5tel";
+    armv6l = buildFor "armv6l";
+    armv7l = buildFor "armv7l";
 }
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index a836f6fdd378..3ad81476c2e9 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -154,92 +154,12 @@ rec {
       allowedReferences = [];
     };
 
-
-  unpack =
-
-    derivation {
-      name = "unpack";
-      inherit system;
-      builder = "${build}/on-server/busybox";
-      args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
-
-      buildCommand = ''
-        export PATH=${build}/on-server:$out/bin
-
-        busybox mkdir $out
-        < ${build}/on-server/bootstrap-tools.tar.xz busybox unxz | busybox tar x -C $out
-
-        for i in $out/bin/* $out/libexec/gcc/*/*/*; do
-            if [ -L "$i" ]; then continue; fi
-            if [ -z "''${i##*/liblto*}" ]; then continue; fi
-            echo patching "$i"
-            LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \
-                $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath "$i"
-        done
-
-        for i in $out/lib/libpcre*; do
-            if [ -L "$i" ]; then continue; fi
-            echo patching "$i"
-            $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
-        done
-
-        # Fix the libc linker script.
-        for i in $out/lib/libc.so; do
-            cat $i | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $i.tmp
-            mv $i.tmp $i
-        done
-      ''; # " */
-
-      allowedReferences = ["out"];
-    };
-
-
-  test =
-
-    derivation {
-      name = "test";
-      inherit system;
-      builder = "${build}/on-server/busybox";
-      args = [ "ash" "-e" "-c" "eval \"$buildCommand\"" ];
-
-      buildCommand = ''
-        export PATH=${unpack}/bin
-        ls -l
-        mkdir $out
-        mkdir $out/bin
-        sed --version
-        find --version
-        diff --version
-        patch --version
-        make --version
-        awk --version
-        grep --version
-        gcc --version
-        curl --version
-
-        ldlinux=$(echo ${unpack}/lib/ld-linux*.so.2)
-
-        export CPP="cpp -idirafter ${unpack}/include-glibc -B${unpack}"
-        export CC="gcc -idirafter ${unpack}/include-glibc -B${unpack} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${unpack}/lib"
-        export CXX="g++ -idirafter ${unpack}/include-glibc -B${unpack} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${unpack}/lib"
-
-        echo '#include <stdio.h>' >> foo.c
-        echo '#include <limits.h>' >> foo.c
-        echo 'int main() { printf("Hello World\\n"); return 0; }' >> foo.c
-        $CC -o $out/bin/foo foo.c
-        $out/bin/foo
-
-        echo '#include <iostream>' >> bar.cc
-        echo 'int main() { std::cout << "Hello World\\n"; }' >> bar.cc
-        $CXX -v -o $out/bin/bar bar.cc
-        $out/bin/bar
-
-        tar xvf ${hello.src}
-        cd hello-*
-        ./configure --prefix=$out
-        make
-        make install
-      ''; # */
+  test = ((import ./default.nix) {
+    inherit system;
+    
+    customBootstrapFiles = {
+      busybox = "${build}/on-server/busybox";
+      bootstrapTools = "${build}/on-server/bootstrap-tools.tar.xz";
     };
-
+  }).testBootstrapTools;
 }
diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh
deleted file mode 100644
index dcf819ad6f75..000000000000
--- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-set -e
-
-# Unpack the bootstrap tools tarball.
-echo Unpacking the bootstrap tools...
-$mkdir $out
-$bzip2 -d < $tarball | (cd $out && $cpio -V -i)
-
-# Set the ELF interpreter / RPATH in the bootstrap binaries.
-echo Patching the bootstrap tools...
-
-# On x86_64, ld-linux-x86-64.so.2 barfs on patchelf'ed programs.  So
-# use a copy of patchelf.
-LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? $out/bin/cp $out/bin/patchelf .
-
-for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do
-    if test ${i%.la} != $i; then continue; fi
-    if test ${i%*.so*} != $i; then continue; fi
-    if ! test -f $i; then continue; fi
-    if test -L $i; then continue; fi
-    echo patching $i
-    LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-        $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
-    LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-        $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i
-done
-for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp*; do
-    if ! test -f $i; then continue; fi
-    if test -L $i; then continue; fi
-    echo patching $i
-    LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-        $out/bin/patchelf --set-rpath $out/lib --force-rpath $i
-    LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \
-        $out/bin/patchelf --set-rpath $out/lib --force-rpath $i
-done
-
-# Fix the libc linker script.
-export PATH=$out/bin
-cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp
-mv $out/lib/libc.so.tmp $out/lib/libc.so
-cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp
-mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
-
-# Provide some additional symlinks.
-ln -s bash $out/bin/sh
-ln -s bzip2 $out/bin/bunzip2
-
-# Mimic the gunzip script as in gzip installations
-cat > $out/bin/gunzip <<EOF
-#!$out/bin/sh
-exec $out/bin/gzip -d "\$@"
-EOF
-chmod +x $out/bin/gunzip
-
-# fetchurl needs curl.
-bzip2 -d < $curl > $out/bin/curl
-chmod +x $out/bin/curl
diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
index 52953c9b88da..efec363c5c79 100644
--- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
+++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools.sh
@@ -22,11 +22,11 @@ for i in $out/bin/* $out/libexec/gcc/*/*/*; do
     if [ -L "$i" ]; then continue; fi
     if [ -z "${i##*/liblto*}" ]; then continue; fi
     echo patching "$i"
-    LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \
+    LD_LIBRARY_PATH=$out/lib $LD_BINARY \
         $out/bin/patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
 done
 
-for i in $out/lib/libpcre*; do
+for i in $out/lib/librt-*.so $out/lib/libpcre*; do
     if [ -L "$i" ]; then continue; fi
     echo patching "$i"
     $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"