Skip to content

Commit

Permalink
zig_0_13: fix darwin SDK lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaskorz committed Jan 24, 2025
1 parent 550e2ab commit 57bd267
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pkgs/development/compilers/zig/0.13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ stdenv.mkDerivation (finalAttrs: {
# https://github.com/NixOS/nixpkgs/issues/317055#issuecomment-2148438395
strictDeps = !stdenv.cc.isClang;

# Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
# work in Nix's sandbox. Use env from our coreutils instead.
postPatch = ''
substituteInPlace lib/std/zig/system.zig \
--replace "/usr/bin/env" "${lib.getExe' coreutils "env"}"
'';
postPatch =
# Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
# work in Nix's sandbox. Use env from our coreutils instead.
''
substituteInPlace lib/std/zig/system.zig \
--replace "/usr/bin/env" "${lib.getExe' coreutils "env"}"
''
# Zig tries to access xcrun at the absolute system path to query the macOS SDK
# location, which does not work in the darwin sandbox.
# We can just provide "xcrun" instead as it is part of the darwin stdenv.
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace lib/std/zig/system/darwin.zig \
--replace-fail /usr/bin/xcrun xcrun
'';

postBuild = ''
stage3/bin/zig build langref
Expand Down

0 comments on commit 57bd267

Please sign in to comment.