Commit 90cf03cc authored by Niklas Korz's avatar Niklas Korz
Browse files

zig: refactor system env substitution

parent 0ae3ecb3
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -87,18 +87,17 @@ 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 =
    (
    let
      zigSystemPath =
        if lib.versionAtLeast finalAttrs.version "0.12" then
        ''
          substituteInPlace lib/std/zig/system.zig \
            --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
        ''
          "lib/std/zig/system.zig"
        else
          "lib/std/zig/system/NativeTargetInfo.zig";
    in
    ''
          substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
            --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
      substituteInPlace ${zigSystemPath} \
        --replace-fail "/usr/bin/env" "${lib.getExe' coreutils "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