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