at 25.11-pre 128 lines 2.9 kB view raw
1{ 2 lib, 3 buildPlatform, 4 hostPlatform, 5 fetchurl, 6 bootBash, 7 gnumake, 8 gnupatch, 9 gnused, 10 gnugrep, 11 gnutar, 12 gawk, 13 gzip, 14 diffutils, 15 tinycc, 16 derivationWithMeta, 17 bash, 18 coreutils, 19}: 20let 21 pname = "bash"; 22 version = "5.2.15"; 23 24 src = fetchurl { 25 url = "mirror://gnu/bash/bash-${version}.tar.gz"; 26 sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; 27 }; 28 29 patches = [ 30 # flush output for generated code 31 ./mksignames-flush.patch 32 ]; 33in 34bootBash.runCommand "${pname}-${version}" 35 { 36 inherit pname version; 37 38 nativeBuildInputs = [ 39 coreutils 40 tinycc.compiler 41 gnumake 42 gnupatch 43 gnused 44 gnugrep 45 gnutar 46 gawk 47 gzip 48 diffutils 49 ]; 50 51 passthru.runCommand = 52 name: env: buildCommand: 53 derivationWithMeta ( 54 { 55 inherit name buildCommand; 56 builder = "${bash}/bin/bash"; 57 args = [ 58 "-e" 59 (builtins.toFile "bash-builder.sh" '' 60 export CONFIG_SHELL=$SHELL 61 62 # Normalize the NIX_BUILD_CORES variable. The value might be 0, which 63 # means that we're supposed to try and auto-detect the number of 64 # available CPU cores at run-time. 65 NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" 66 if ((NIX_BUILD_CORES <= 0)); then 67 guess=$(nproc 2>/dev/null || true) 68 ((NIX_BUILD_CORES = guess <= 0 ? 1 : guess)) 69 fi 70 export NIX_BUILD_CORES 71 72 bash -eux $buildCommandPath 73 '') 74 ]; 75 passAsFile = [ "buildCommand" ]; 76 77 SHELL = "${bash}/bin/bash"; 78 PATH = lib.makeBinPath ( 79 (env.nativeBuildInputs or [ ]) 80 ++ [ 81 bash 82 coreutils 83 ] 84 ); 85 } 86 // (builtins.removeAttrs env [ "nativeBuildInputs" ]) 87 ); 88 89 passthru.tests.get-version = 90 result: 91 bootBash.runCommand "${pname}-get-version-${version}" { } '' 92 ${result}/bin/bash --version 93 mkdir $out 94 ''; 95 96 meta = with lib; { 97 description = "GNU Bourne-Again Shell, the de facto standard shell on Linux"; 98 homepage = "https://www.gnu.org/software/bash"; 99 license = licenses.gpl3Plus; 100 teams = [ teams.minimal-bootstrap ]; 101 platforms = platforms.unix; 102 }; 103 } 104 '' 105 # Unpack 106 tar xzf ${src} 107 cd bash-${version} 108 109 # Patch 110 ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} 111 112 # Configure 113 export CC="tcc -B ${tinycc.libs}/lib" 114 export AR="tcc -ar" 115 export LD=tcc 116 bash ./configure \ 117 --prefix=$out \ 118 --build=${buildPlatform.config} \ 119 --host=${hostPlatform.config} \ 120 --without-bash-malloc 121 122 # Build 123 make -j $NIX_BUILD_CORES SHELL=bash 124 125 # Install 126 make -j $NIX_BUILD_CORES install 127 ln -s bash $out/bin/sh 128 ''