diff options
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix')
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix index dea5ad9f017..86fa3a58687 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix @@ -4,15 +4,14 @@ , fetchurl , bootBash , gnumake +, gnupatch , gnused , gnugrep , gnutar , gawk , gzip -, gcc -, glibc -, binutils -, linux-headers +, diffutils +, tinycc , derivationWithMeta , bash , coreutils @@ -25,19 +24,26 @@ let url = "mirror://gnu/bash/bash-${version}.tar.gz"; sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; }; + + patches = [ + # flush output for generated code + ./mksignames-flush.patch + ]; in bootBash.runCommand "${pname}-${version}" { inherit pname version; nativeBuildInputs = [ - gcc - binutils + coreutils + tinycc.compiler gnumake + gnupatch gnused gnugrep gnutar gawk gzip + diffutils ]; passthru.runCommand = name: env: buildCommand: @@ -48,6 +54,17 @@ bootBash.runCommand "${pname}-${version}" { "-e" (builtins.toFile "bash-builder.sh" '' export CONFIG_SHELL=$SHELL + + # Normalize the NIX_BUILD_CORES variable. The value might be 0, which + # means that we're supposed to try and auto-detect the number of + # available CPU cores at run-time. + NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" + if ((NIX_BUILD_CORES <= 0)); then + guess=$(nproc 2>/dev/null || true) + ((NIX_BUILD_CORES = guess <= 0 ? 1 : guess)) + fi + export NIX_BUILD_CORES + bash -eux $buildCommandPath '') ]; @@ -78,22 +95,23 @@ bootBash.runCommand "${pname}-${version}" { tar xzf ${src} cd bash-${version} + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + # Configure - export CC="gcc -I${glibc}/include -I${linux-headers}/include" - export LIBRARY_PATH="${glibc}/lib" - export LIBS="-lc -lnss_files -lnss_dns -lresolv" - export ac_cv_func_dlopen=no + export CC="tcc -B ${tinycc.libs}/lib" + export AR="tcc -ar" + export LD=tcc bash ./configure \ --prefix=$out \ --build=${buildPlatform.config} \ --host=${hostPlatform.config} \ - --disable-nls \ - --disable-net-redirections + --without-bash-malloc # Build - make SHELL=bash + make -j $NIX_BUILD_CORES SHELL=bash # Install - make install + make -j $NIX_BUILD_CORES install ln -s bash $out/bin/sh '' |