stdenv: create env-vars file before writing data to it

This fixes the regression introduced by c47a1e701d
on Darwin. The creation of the file using `install` and process
substitution does not work on Darwin, you get the following complain:
```
install: skipping file '/dev/fd/63', as it was replaced while being copied
```

Fixes #335016
This commit is contained in:
Thomas Gerbet 2024-08-18 14:18:02 +02:00
parent 6855a1a5f4
commit d00775c1d9

View File

@ -1121,7 +1121,13 @@ substituteAllInPlace() {
# the environment used for building.
dumpVars() {
if [ "${noDumpEnvVars:-0}" != 1 ]; then
install -m 0600 <(export 2>/dev/null) "$NIX_BUILD_TOP/env-vars" || true
# On darwin, install(1) cannot be called with /dev/stdin or fd from process substitution
# so first we create the file and then write to it
# See https://github.com/NixOS/nixpkgs/issues/335016
{
install -m 0600 /dev/null "$NIX_BUILD_TOP/env-vars" &&
export 2>/dev/null >| "$NIX_BUILD_TOP/env-vars"
} || true
fi
}