15 stdenv.mkDerivation (finalAttrs: {
18 src = fetchFromGitHub {
21 rev = finalAttrs.version;
33 ] ++ (with llvmPackages; [
39 # On Darwin, Zig calls std.zig.system.darwin.macos.detect during the build,
40 # which parses /System/Library/CoreServices/SystemVersion.plist and
41 # /System/Library/CoreServices/.SystemVersionPlatform.plist to determine the
42 # OS version. This causes the build to fail during stage 3 with
43 # OSVersionDetectionFail when the sandbox is enabled.
44 __impureHostDeps = lib.optionals stdenv.hostPlatform.isDarwin [
45 "/System/Library/CoreServices/.SystemVersionPlatform.plist"
46 "/System/Library/CoreServices/SystemVersion.plist"
50 export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-cache";
53 # Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
54 # work in Nix's sandbox. Use env from our coreutils instead.
55 postPatch = if lib.versionAtLeast args.version "0.12" then ''
56 substituteInPlace lib/std/zig/system.zig \
57 --replace "/usr/bin/env" "${coreutils}/bin/env"
59 substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
60 --replace-fail "/usr/bin/env" "${coreutils}/bin/env"
63 doInstallCheck = true;
64 installCheckPhase = ''
65 runHook preInstallCheck
67 $out/bin/zig test -I $src/test $src/test/behavior.zig
69 runHook postInstallCheck
73 hook = callPackage ./hook.nix {
74 zig = finalAttrs.finalPackage;
76 cc = callPackage ./cc.nix {
77 zig = finalAttrs.finalPackage;
79 stdenv = callPackage ./stdenv.nix {
80 zig = finalAttrs.finalPackage;
85 description = "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
86 homepage = "https://ziglang.org/";
87 changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html";
88 license = lib.licenses.mit;
89 maintainers = with lib.maintainers; [ andrewrk ] ++ lib.teams.zig.members;
91 platforms = lib.platforms.unix;
93 } // removeAttrs args [ "hash" ])