diff options
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap/bash')
3 files changed, 53 insertions, 14 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix b/pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix index 41e3547a786..5eea877803a 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix @@ -84,6 +84,17 @@ kaem.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. We don't have nproc to detect the + # number of available CPU cores so default to 1 if not set. + NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" + if [ $NIX_BUILD_CORES -le 0 ]; then + NIX_BUILD_CORES=1 + fi + export NIX_BUILD_CORES + bash -eux $buildCommandPath '') ]; 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 '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch b/pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch new file mode 100644 index 00000000000..6e64dfa7fa3 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/mksignames-flush.patch @@ -0,0 +1,10 @@ +--- a/support/mksignames.c ++++ b/support/mksignames.c +@@ -68,6 +68,7 @@ write_signames (stream) + fprintf (stream, "};\n\n"); + fprintf (stream, "#define initialize_signames()\n\n"); + #endif ++ fflush(stream); + } + + int |