Added /usr/bin/env fix from nixpkgs #62
Open
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.
Currently, when using zig-overlay to compile zig code in a nix flake via
nix buildor the other nix-based build commands, which run the build in a nix sandbox, it will throwerror.FileNotFoundwhen attempting to detect the ABI and the linker, and will always fall back to the default one.This patch to
lib/std/zig/system.zigreplaces the hardcoded/usr/bin/envpath with a reference to the nix store coreutils bin/env path, which is pulled from the nixpkgs input of the flake.Offending code:
https://github.com/ziglang/zig/blob/d5db02728ce3ff3ba74a3e3f9050c3ea9ed34752/lib/std/zig/system.zig#L1088
Patch source:
https://github.com/NixOS/nixpkgs/blob/5df43628fdf08d642be8ba5b3625a6c70731c19c/pkgs/development/compilers/zig/0.13/default.nix#L73-L78
Patched zig example:

It also pollutes the comments in that file that mention /usr/bin/env, but that's not really an issue