at v206 5.2 kB view raw
1{ system ? builtins.currentSystem }: 2 3with import ../../top-level/all-packages.nix {inherit system;}; 4 5rec { 6 7 8 # We want coreutils without ACL support. 9 coreutilsMinimal = coreutils.override (args: { 10 aclSupport = false; 11 }); 12 13 curlMinimal = curl.override { 14 zlibSupport = false; 15 sslSupport = false; 16 scpSupport = false; 17 }; 18 19 busyboxMinimal = busybox.override { 20 useMusl = true; 21 enableStatic = true; 22 enableMinimal = true; 23 extraConfig = '' 24 CONFIG_ASH y 25 CONFIG_ASH_BUILTIN_ECHO y 26 CONFIG_ASH_BUILTIN_TEST y 27 CONFIG_ASH_OPTIMIZE_FOR_SIZE y 28 CONFIG_MKDIR y 29 CONFIG_TAR y 30 CONFIG_UNXZ y 31 ''; 32 }; 33 34 build = 35 36 stdenv.mkDerivation { 37 name = "build"; 38 39 buildInputs = [nukeReferences cpio]; 40 41 buildCommand = '' 42 set -x 43 mkdir -p $out/bin $out/lib $out/libexec 44 45 # Copy what we need of Glibc. 46 cp -d ${glibc}/lib/ld*.so* $out/lib 47 cp -d ${glibc}/lib/libc*.so* $out/lib 48 cp -d ${glibc}/lib/libc_nonshared.a $out/lib 49 cp -d ${glibc}/lib/libm*.so* $out/lib 50 cp -d ${glibc}/lib/libdl*.so* $out/lib 51 cp -d ${glibc}/lib/librt*.so* $out/lib 52 cp -d ${glibc}/lib/libpthread*.so* $out/lib 53 cp -d ${glibc}/lib/libnsl*.so* $out/lib 54 cp -d ${glibc}/lib/libutil*.so* $out/lib 55 cp -d ${glibc}/lib/libnss*.so* $out/lib 56 cp -d ${glibc}/lib/libresolv*.so* $out/lib 57 cp -d ${glibc}/lib/crt?.o $out/lib 58 59 cp -rL ${glibc}/include $out 60 chmod -R u+w $out/include 61 62 # Hopefully we won't need these. 63 rm -rf $out/include/mtd $out/include/rdma $out/include/sound $out/include/video 64 find $out/include -name .install -exec rm {} \; 65 find $out/include -name ..install.cmd -exec rm {} \; 66 mv $out/include $out/include-glibc 67 68 # Copy coreutils, bash, etc. 69 cp ${coreutilsMinimal}/bin/* $out/bin 70 (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users) 71 72 cp ${bash}/bin/bash $out/bin 73 cp ${findutils}/bin/find $out/bin 74 cp ${findutils}/bin/xargs $out/bin 75 cp -d ${diffutils}/bin/* $out/bin 76 cp -d ${gnused}/bin/* $out/bin 77 cp -d ${gnugrep}/bin/grep $out/bin 78 cp ${gawk}/bin/gawk $out/bin 79 cp -d ${gawk}/bin/awk $out/bin 80 cp ${gnutar}/bin/tar $out/bin 81 cp ${gzip}/bin/gzip $out/bin 82 cp ${bzip2}/bin/bzip2 $out/bin 83 cp -d ${gnumake}/bin/* $out/bin 84 cp -d ${patch}/bin/* $out/bin 85 cp ${patchelf}/bin/* $out/bin 86 cp ${curlMinimal}/bin/curl $out/bin 87 cp -d ${curlMinimal}/lib/libcurl* $out/lib 88 89 cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep 90 91 # Copy what we need of GCC. 92 cp -d ${gcc.cc}/bin/gcc $out/bin 93 cp -d ${gcc.cc}/bin/cpp $out/bin 94 cp -d ${gcc.cc}/bin/g++ $out/bin 95 cp -d ${gcc.cc}/lib*/libgcc_s.so* $out/lib 96 cp -d ${gcc.cc}/lib*/libstdc++.so* $out/lib 97 cp -rd ${gcc.cc}/lib/gcc $out/lib 98 chmod -R u+w $out/lib 99 rm -f $out/lib/gcc/*/*/include*/linux 100 rm -f $out/lib/gcc/*/*/include*/sound 101 rm -rf $out/lib/gcc/*/*/include*/root 102 rm -f $out/lib/gcc/*/*/include-fixed/asm 103 rm -rf $out/lib/gcc/*/*/plugin 104 #rm -f $out/lib/gcc/*/*/*.a 105 cp -rd ${gcc.cc}/libexec/* $out/libexec 106 chmod -R u+w $out/libexec 107 rm -rf $out/libexec/gcc/*/*/plugin 108 mkdir $out/include 109 cp -rd ${gcc.cc}/include/c++ $out/include 110 chmod -R u+w $out/include 111 rm -rf $out/include/c++/*/ext/pb_ds 112 rm -rf $out/include/c++/*/ext/parallel 113 114 cp -d ${gmpxx}/lib/libgmp*.so* $out/lib 115 cp -d ${mpfr}/lib/libmpfr*.so* $out/lib 116 cp -d ${libmpc}/lib/libmpc*.so* $out/lib 117 cp -d ${zlib}/lib/libz.so* $out/lib 118 cp -d ${libelf}/lib/libelf.so* $out/lib 119 120 # Copy binutils. 121 for i in as ld ar ranlib nm strip readelf objdump; do 122 cp ${binutils}/bin/$i $out/bin 123 done 124 cp -d ${binutils}/lib/lib*.so* $out/lib 125 126 chmod -R u+w $out 127 128 # Strip executables even further. 129 for i in $out/bin/* $out/libexec/gcc/*/*/*; do 130 if test -x $i -a ! -L $i; then 131 chmod +w $i 132 strip -s $i || true 133 fi 134 done 135 136 nuke-refs $out/bin/* 137 nuke-refs $out/lib/* 138 nuke-refs $out/libexec/gcc/*/*/* 139 140 mkdir $out/.pack 141 mv $out/* $out/.pack 142 mv $out/.pack $out/pack 143 144 mkdir $out/on-server 145 tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack . 146 cp ${busyboxMinimal}/bin/busybox $out/on-server 147 chmod u+w $out/on-server/busybox 148 nuke-refs $out/on-server/busybox 149 ''; # */ 150 151 # The result should not contain any references (store paths) so 152 # that we can safely copy them out of the store and to other 153 # locations in the store. 154 allowedReferences = []; 155 }; 156 157 test = ((import ./default.nix) { 158 inherit system; 159 160 customBootstrapFiles = { 161 busybox = "${build}/on-server/busybox"; 162 bootstrapTools = "${build}/on-server/bootstrap-tools.tar.xz"; 163 }; 164 }).testBootstrapTools; 165}