about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/development/compilers/zig/0.12.nix37
-rw-r--r--pkgs/development/compilers/zig/generic.nix5
-rw-r--r--pkgs/top-level/all-packages.nix4
3 files changed, 45 insertions, 1 deletions
diff --git a/pkgs/development/compilers/zig/0.12.nix b/pkgs/development/compilers/zig/0.12.nix
new file mode 100644
index 0000000000000..e234b600bc227
--- /dev/null
+++ b/pkgs/development/compilers/zig/0.12.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, llvmPackages
+, libxml2
+, zlib
+, coreutils
+, callPackage
+}@args:
+
+import ./generic.nix args {
+  version = "0.12.0";
+
+  hash = "sha256-RNZiUZtaKXoab5kFrDij6YCAospeVvlLWheTc3FGMks=";
+
+  outputs = [ "out" "doc" ];
+
+  cmakeFlags = [
+    # file RPATH_CHANGE could not write new RPATH
+    (lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
+
+    # always link against static build of LLVM
+    (lib.cmakeBool "ZIG_STATIC_LLVM" true)
+
+    # ensure determinism in the compiler build
+    (lib.cmakeFeature "ZIG_TARGET_MCPU" "baseline")
+  ];
+
+  postBuild = ''
+    stage3/bin/zig run ../tools/docgen.zig -- ../doc/langref.html.in langref.html --zig $PWD/stage3/bin/zig
+  '';
+
+  postInstall = ''
+    install -Dm444 langref.html -t $doc/share/doc/zig-$version/html
+  '';
+}
diff --git a/pkgs/development/compilers/zig/generic.nix b/pkgs/development/compilers/zig/generic.nix
index 220f3240f2852..f3c725e1e5ce0 100644
--- a/pkgs/development/compilers/zig/generic.nix
+++ b/pkgs/development/compilers/zig/generic.nix
@@ -40,7 +40,10 @@ 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 = ''
+  postPatch = if lib.versionAtLeast args.version "0.12" then ''
+    substituteInPlace lib/std/zig/system.zig \
+      --replace "/usr/bin/env" "${coreutils}/bin/env"
+  '' else ''
     substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
       --replace "/usr/bin/env" "${coreutils}/bin/env"
   '';
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index bf1320fe2b137..7da15de9c8a7a 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -25239,6 +25239,10 @@ with pkgs;
   zig_0_11 = darwin.apple_sdk_11_0.callPackage ../development/compilers/zig/0.11.nix {
     llvmPackages = llvmPackages_16;
   };
+  # requires a newer Apple SDK
+  zig_0_12 = darwin.apple_sdk_11_0.callPackage ../development/compilers/zig/0.12.nix {
+    llvmPackages = llvmPackages_17;
+  };
   zig = zig_0_11;
 
   zig-shell-completions = callPackage ../development/compilers/zig/shell-completions.nix { };