stdenv: warn about duplicate programs in PATH #329117
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes
When adding packages to build inputs, multiple packages may provide the same program. This is not always intentional, e.g. for Darwin, adding cctools package partially overrides tools from stdenv’s cc attribute (that is provided to derivations as a default native build input and hence is lower on the search path). Note that we don’t currently set CC/AR/etc to absolute paths.
This change adds checks right after the PATH is constructed in stdenv’s setup.sh to warn about duplicate programs on the PATH search path.
Example output
The implementation currently focuses on Unix-like PATH. Windows has a bit more rules for PATH lookups, but we don’t support Windows as a build platform. If Nix and Nixpkgs eventually get ported to Windows, the name of the function should hopefully hint that it should be updated to match the platform semantics.
For convenience, this change also adds isExecutable function to the stdenv that checks whether a file has executable file mode bit set.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.