Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at master 98 lines 2.5 kB view raw
1{ 2 pkgs ? import ../../.. { }, 3}: 4 5let 6 inherit (pkgs) 7 lib 8 stdenv 9 config 10 libc 11 ; 12 13 patchelf = pkgs.patchelf.overrideAttrs (previousAttrs: { 14 NIX_CFLAGS_COMPILE = (previousAttrs.NIX_CFLAGS_COMPILE or [ ]) ++ [ 15 "-static-libgcc" 16 "-static-libstdc++" 17 ]; 18 NIX_CFLAGS_LINK = (previousAttrs.NIX_CFLAGS_LINK or [ ]) ++ [ 19 "-static-libgcc" 20 "-static-libstdc++" 21 ]; 22 }); 23in 24rec { 25 coreutilsMinimal = pkgs.coreutils.override (args: { 26 # We want coreutils without ACL/attr support. 27 aclSupport = false; 28 attrSupport = false; 29 # Our tooling currently can't handle scripts in bin/, only ELFs and symlinks. 30 singleBinary = "symlinks"; 31 }); 32 33 tarMinimal = pkgs.gnutar.override { acl = null; }; 34 35 busyboxMinimal = pkgs.busybox.override { 36 useMusl = lib.meta.availableOn stdenv.hostPlatform pkgs.musl; 37 enableStatic = true; 38 enableMinimal = true; 39 extraConfig = '' 40 CONFIG_ASH y 41 CONFIG_ASH_ECHO y 42 CONFIG_ASH_TEST y 43 CONFIG_ASH_OPTIMIZE_FOR_SIZE y 44 CONFIG_MKDIR y 45 CONFIG_TAR y 46 CONFIG_UNXZ y 47 ''; 48 }; 49 50 bootGCC = 51 (pkgs.gcc.cc.override { 52 enableLTO = false; 53 isl = null; 54 }).overrideAttrs 55 (old: { 56 patches = old.patches or [ ] ++ [ 57 (pkgs.fetchpatch { 58 # c++tools: Don't check --enable-default-pie. 59 # --enable-default-pie breaks bootstrap gcc otherwise, because libiberty.a is not found 60 url = "https://github.com/gcc-mirror/gcc/commit/3f1f99ef82a65d66e3aaa429bf4fb746b93da0db.patch"; 61 hash = "sha256-wKVuwrW22gSN1woYFYxsyVk49oYmbogIN6FWbU8cVds="; 62 }) 63 ]; 64 }); 65 66 bootBinutils = pkgs.binutils.bintools.override { 67 withAllTargets = false; 68 # Don't need two linkers, disable whatever's not primary/default. 69 enableGold = false; 70 # bootstrap is easier w/static 71 enableShared = false; 72 }; 73 74 build = pkgs.callPackage ./stdenv-bootstrap-tools.nix { 75 inherit 76 bootBinutils 77 coreutilsMinimal 78 tarMinimal 79 busyboxMinimal 80 bootGCC 81 libc 82 patchelf 83 ; 84 }; 85 86 inherit (build) bootstrapFiles; 87 88 bootstrapTools = import ./bootstrap-tools { 89 inherit (stdenv.buildPlatform) system; # Used to determine where to build 90 inherit (stdenv.hostPlatform) libc; 91 inherit lib bootstrapFiles config; 92 }; 93 94 test = pkgs.callPackage ./test-bootstrap-tools.nix { 95 inherit bootstrapTools; 96 inherit (bootstrapFiles) busybox; 97 }; 98}