mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-16 15:58:36 +00:00
stdenv: fix nix_build_cores guess
- use builtin arithmetic instead of external expr - simplify logic with bash builtins
This commit is contained in:
parent
95a966c5b2
commit
4c92bb8bdf
|
@ -658,15 +658,10 @@ export NIX_INDENT_MAKE=1
|
|||
# means that we're supposed to try and auto-detect the number of
|
||||
# available CPU cores at run-time.
|
||||
|
||||
if [ -z "${NIX_BUILD_CORES:-}" ]; then
|
||||
NIX_BUILD_CORES="1"
|
||||
elif (( NIX_BUILD_CORES <= 0 )); then
|
||||
NIX_BUILD_CORES=$(nproc 2>/dev/null || true)
|
||||
if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then
|
||||
:
|
||||
else
|
||||
NIX_BUILD_CORES="1"
|
||||
fi
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue