diff options
author | John Ericson <git@JohnEricson.me> | 2023-10-31 11:09:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-31 11:09:07 -0400 |
commit | b67d49726047b20713c3a48710d7459031ff361f (patch) | |
tree | 68d5924e772a84afd09f836c338c77870fcddc97 /pkgs | |
parent | 4a644c17c07afeaca26bc2c6c67534fa2c176209 (diff) | |
parent | 4f62cc0388847299d25e8b21bd5021ee6f745fd6 (diff) |
Merge pull request #262847 from emilytrau/minimal-nix-cores
minimal-bootstrap.bash{,_2_05}: Normalize the NIX_BUILD_CORES variable
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix | 11 | ||||
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix | 11 | ||||
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/default.nix | 3 |
3 files changed, 22 insertions, 3 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix b/pkgs/os-specific/linux/minimal-bootstrap/bash/2.nix index 41e3547a7861..5eea877803a5 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 35c4da7acf93..86fa3a58687b 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/bash/default.nix @@ -54,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 '') ]; diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 11b7f5b11a6f..a246b587dd4f 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -24,14 +24,12 @@ lib.makeScope }; binutils = callPackage ./binutils { - bash = bash_2_05; tinycc = tinycc-musl; gnumake = gnumake-musl; gnutar = gnutar-musl; }; bzip2 = callPackage ./bzip2 { - bash = bash_2_05; tinycc = tinycc-musl; gnumake = gnumake-musl; gnutar = gnutar-musl; @@ -53,7 +51,6 @@ lib.makeScope }; findutils = callPackage ./findutils { - bash = bash_2_05; tinycc = tinycc-musl; gnumake = gnumake-musl; gnutar = gnutar-musl; |