Loading pkgs/development/compilers/zig/generic.nix +33 −14 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ fetchFromGitHub, cmake, llvmPackages, xcbuild, targetPackages, libxml2, zlib, Loading @@ -30,9 +31,14 @@ stdenv.mkDerivation (finalAttrs: { patches = args.patches or [ ]; nativeBuildInputs = [ nativeBuildInputs = [ cmake (lib.getDev llvmPackages.llvm.dev) ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # provides xcode-select, which is required for SDK detection xcbuild ]; buildInputs = Loading Loading @@ -81,6 +87,7 @@ stdenv.mkDerivation (finalAttrs: { # 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 = ( if lib.versionAtLeast finalAttrs.version "0.12" then '' substituteInPlace lib/std/zig/system.zig \ Loading @@ -90,6 +97,18 @@ stdenv.mkDerivation (finalAttrs: { '' substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \ --replace-fail "/usr/bin/env" "${coreutils}/bin/env" '' ) # Zig tries to access xcrun and xcode-select at the absolute system path to query the macOS SDK # location, which does not work in the darwin sandbox. # Upstream issue: https://github.com/ziglang/zig/issues/22600 # Note that while this fix is already merged upstream and will be included in 0.14+, # we can't fetchpatch the upstream commit as it won't cleanly apply on older versions, # so we substitute the paths instead. + lib.optionalString (stdenv.hostPlatform.isDarwin && lib.versionOlder finalAttrs.version "0.14") '' substituteInPlace lib/std/zig/system/darwin.zig \ --replace-fail /usr/bin/xcrun xcrun \ --replace-fail /usr/bin/xcode-select xcode-select ''; postBuild = Loading pkgs/development/compilers/zig/hook.nix +7 −1 Original line number Diff line number Diff line Loading @@ -2,12 +2,18 @@ lib, makeSetupHook, zig, stdenv, xcbuild, }: makeSetupHook { name = "zig-hook"; propagatedBuildInputs = [ zig ]; propagatedBuildInputs = [ zig ] # while xcrun is already included in the darwin stdenv, Zig also needs # xcode-select (provided by xcbuild) for SDK detection ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ]; substitutions = { # This zig_default_flags below is meant to avoid CPU feature impurity in Loading Loading
pkgs/development/compilers/zig/generic.nix +33 −14 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ fetchFromGitHub, cmake, llvmPackages, xcbuild, targetPackages, libxml2, zlib, Loading @@ -30,9 +31,14 @@ stdenv.mkDerivation (finalAttrs: { patches = args.patches or [ ]; nativeBuildInputs = [ nativeBuildInputs = [ cmake (lib.getDev llvmPackages.llvm.dev) ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # provides xcode-select, which is required for SDK detection xcbuild ]; buildInputs = Loading Loading @@ -81,6 +87,7 @@ stdenv.mkDerivation (finalAttrs: { # 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 = ( if lib.versionAtLeast finalAttrs.version "0.12" then '' substituteInPlace lib/std/zig/system.zig \ Loading @@ -90,6 +97,18 @@ stdenv.mkDerivation (finalAttrs: { '' substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \ --replace-fail "/usr/bin/env" "${coreutils}/bin/env" '' ) # Zig tries to access xcrun and xcode-select at the absolute system path to query the macOS SDK # location, which does not work in the darwin sandbox. # Upstream issue: https://github.com/ziglang/zig/issues/22600 # Note that while this fix is already merged upstream and will be included in 0.14+, # we can't fetchpatch the upstream commit as it won't cleanly apply on older versions, # so we substitute the paths instead. + lib.optionalString (stdenv.hostPlatform.isDarwin && lib.versionOlder finalAttrs.version "0.14") '' substituteInPlace lib/std/zig/system/darwin.zig \ --replace-fail /usr/bin/xcrun xcrun \ --replace-fail /usr/bin/xcode-select xcode-select ''; postBuild = Loading
pkgs/development/compilers/zig/hook.nix +7 −1 Original line number Diff line number Diff line Loading @@ -2,12 +2,18 @@ lib, makeSetupHook, zig, stdenv, xcbuild, }: makeSetupHook { name = "zig-hook"; propagatedBuildInputs = [ zig ]; propagatedBuildInputs = [ zig ] # while xcrun is already included in the darwin stdenv, Zig also needs # xcode-select (provided by xcbuild) for SDK detection ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ]; substitutions = { # This zig_default_flags below is meant to avoid CPU feature impurity in Loading