···4 fetchFromGitHub,
5 cmake,
6 llvmPackages,
07 targetPackages,
8 libxml2,
9 zlib,
···3031 patches = args.patches or [ ];
3233- nativeBuildInputs = [
34- cmake
35- (lib.getDev llvmPackages.llvm.dev)
36- ];
000003738 buildInputs =
39 [
···81 # Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
82 # work in Nix's sandbox. Use env from our coreutils instead.
83 postPatch =
84- if lib.versionAtLeast finalAttrs.version "0.12" then
85- ''
86- substituteInPlace lib/std/zig/system.zig \
87- --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
88- ''
89- else
90- ''
91- substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
92- --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
93- '';
00000000000009495 postBuild =
96 if lib.versionAtLeast finalAttrs.version "0.13" then
···4 fetchFromGitHub,
5 cmake,
6 llvmPackages,
7+ xcbuild,
8 targetPackages,
9 libxml2,
10 zlib,
···3132 patches = args.patches or [ ];
3334+ nativeBuildInputs =
35+ [
36+ cmake
37+ (lib.getDev llvmPackages.llvm.dev)
38+ ]
39+ ++ lib.optionals stdenv.hostPlatform.isDarwin [
40+ # provides xcode-select, which is required for SDK detection
41+ xcbuild
42+ ];
4344 buildInputs =
45 [
···87 # Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
88 # work in Nix's sandbox. Use env from our coreutils instead.
89 postPatch =
90+ (
91+ if lib.versionAtLeast finalAttrs.version "0.12" then
92+ ''
93+ substituteInPlace lib/std/zig/system.zig \
94+ --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
95+ ''
96+ else
97+ ''
98+ substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
99+ --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
100+ ''
101+ )
102+ # Zig tries to access xcrun and xcode-select at the absolute system path to query the macOS SDK
103+ # location, which does not work in the darwin sandbox.
104+ # Upstream issue: https://github.com/ziglang/zig/issues/22600
105+ # Note that while this fix is already merged upstream and will be included in 0.14+,
106+ # we can't fetchpatch the upstream commit as it won't cleanly apply on older versions,
107+ # so we substitute the paths instead.
108+ + lib.optionalString (stdenv.hostPlatform.isDarwin && lib.versionOlder finalAttrs.version "0.14") ''
109+ substituteInPlace lib/std/zig/system/darwin.zig \
110+ --replace-fail /usr/bin/xcrun xcrun \
111+ --replace-fail /usr/bin/xcode-select xcode-select
112+ '';
113114 postBuild =
115 if lib.versionAtLeast finalAttrs.version "0.13" then
+7-1
pkgs/development/compilers/zig/hook.nix
···2 lib,
3 makeSetupHook,
4 zig,
005}:
67makeSetupHook {
8 name = "zig-hook";
910- propagatedBuildInputs = [ zig ];
00001112 substitutions = {
13 # This zig_default_flags below is meant to avoid CPU feature impurity in
···2 lib,
3 makeSetupHook,
4 zig,
5+ stdenv,
6+ xcbuild,
7}:
89makeSetupHook {
10 name = "zig-hook";
1112+ propagatedBuildInputs =
13+ [ zig ]
14+ # while xcrun is already included in the darwin stdenv, Zig also needs
15+ # xcode-select (provided by xcbuild) for SDK detection
16+ ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
1718 substitutions = {
19 # This zig_default_flags below is meant to avoid CPU feature impurity in