zig: fix build on Darwin with sandbox enabled

During stage 3 of compilation, Zig calls `std.zig.system.darwin.macos.detect`,
which parses /System/Library/CoreServices/.SystemVersionPlatform.plist and
/System/Library/CoreServices/SystemVersion.plist[^1] to determine the OS
version. These paths are inaccessible when the sandbox is enabled, which causes
the build to fail with `OSVersionDetectionFail`[^2]. Fix the build with the
relaxed sandbox option by adding these paths to `__impureHostDeps`.

[^1]: cd62005f19/lib/std/zig/system/darwin/macos.zig
[^2]: https://github.com/NixOS/nixpkgs/issues/287861#issuecomment-2148703491
This commit is contained in:
Alex James
2024-06-16 17:35:52 -05:00
parent b96d99b63d
commit cae03b78b4
3 changed files with 30 additions and 0 deletions

View File

@@ -38,6 +38,16 @@ stdenv.mkDerivation (finalAttrs: {
llvm
]);
# On Darwin, Zig calls std.zig.system.darwin.macos.detect during the build,
# which parses /System/Library/CoreServices/SystemVersion.plist and
# /System/Library/CoreServices/.SystemVersionPlatform.plist to determine the
# OS version. This causes the build to fail during stage 3 with
# OSVersionDetectionFail when the sandbox is enabled.
__impureHostDeps = lib.optionals stdenv.isDarwin [
"/System/Library/CoreServices/.SystemVersionPlatform.plist"
"/System/Library/CoreServices/SystemVersion.plist"
];
outputs = [
"out"
"doc"

View File

@@ -38,6 +38,16 @@ stdenv.mkDerivation (finalAttrs: {
llvm
]);
# On Darwin, Zig calls std.zig.system.darwin.macos.detect during the build,
# which parses /System/Library/CoreServices/SystemVersion.plist and
# /System/Library/CoreServices/.SystemVersionPlatform.plist to determine the
# OS version. This causes the build to fail during stage 3 with
# OSVersionDetectionFail when the sandbox is enabled.
__impureHostDeps = lib.optionals stdenv.isDarwin [
"/System/Library/CoreServices/.SystemVersionPlatform.plist"
"/System/Library/CoreServices/SystemVersion.plist"
];
outputs = [
"out"
"doc"

View File

@@ -36,6 +36,16 @@ stdenv.mkDerivation (finalAttrs: {
llvm
]);
# On Darwin, Zig calls std.zig.system.darwin.macos.detect during the build,
# which parses /System/Library/CoreServices/SystemVersion.plist and
# /System/Library/CoreServices/.SystemVersionPlatform.plist to determine the
# OS version. This causes the build to fail during stage 3 with
# OSVersionDetectionFail when the sandbox is enabled.
__impureHostDeps = lib.optionals stdenv.isDarwin [
"/System/Library/CoreServices/.SystemVersionPlatform.plist"
"/System/Library/CoreServices/SystemVersion.plist"
];
env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache";
# Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't