- `env.ZIG_GLOBAL_CACHE_DIR` does not resolve variables, so
all actions had their cache dir in the current directory, named
'$TMPDIR/zig-cache'.
- zig cache does not conflict, so it's totally fine to reuse it in both
build and tests (thus removing `--cache-dir`).
While we're at this, fix a `substituteInPlace` deprecation warning.
In preparation for the deprecation of `stdenv.isX`.
These shorthands are not conducive to cross-compilation because they
hide the platforms.
Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way
One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059
There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.
```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
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
- migrate it to a dedicated directory, zig/0.12
- can't migrate to by-name
- because of undecipherable darwin.apple_sdk_11_0.callPackage
- nixfmt
- add a simple version test
- migrate it to a dedicated directory, zig/0.11
- can't migrate to by-name
- because of undecipherable darwin.apple_sdk_11_0.callPackage
- nixfmt
- add a simple version test
- migrate it to a dedicated directory, zig/0.10
- can't migrate to by-name
- because of undecipherable darwin.apple_sdk_11_0.callPackage
- nixfmt
- add a simple version test
- migrate it to a dedicated directory, zig/0.9
- can't migrate to by-name
- because of undecipherable darwin.apple_sdk_11_0.callPackage
- nixfmt
- add a simple version test
- Use rec-less, overlay-style overridable recursive attributes (in effect since
NixOS#119942);
- Add decoration hooks over installCheckPhase
- Use doInstallCheck instead of doCheck.
- Directly sets env.ZIG_GLOBAL_CACHE_DIR instead of using preBuild
- Add meta.changelog
Relevant upstream issue: ziglang/zig#14559
The patch is a backport of fixes that landed in zig-master and can
be removed with zig-0.11 release.
Additionally, make sure we link statically against LLVM to avoid
unpleasant runtime surprises originating from mixing static and
dynamic LLVM libraries.
Finally, unbreak Zig 0.10.1 on macOS.
26b9a2f4a1 changes Zig 0.10 to build the
compiler (notably *not* its outputs, at least not by default) with
its baseline CPU target, but we should ideally do it for both versions
to increase reproducibility, as well as increase the number of users who
are able to use Hydra-provided Zig binaries.
This also adds a comment above the flag in 0.10, to explain why we're adding
the flag, as we do with the RPATH one.
See https://github.com/NixOS/nixpkgs/issues/214356 and https://github.com/NixOS/nixpkgs/issues/185665
for further context.