summary refs log tree commit diff
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2023-07-07 20:40:09 -0300
committerAnderson Torres <torres.anderson.85@protonmail.com>2023-07-08 20:40:38 -0300
commitd485da9d0034a72ceb9679c2ab0156c073f66b82 (patch)
tree03527299a33616acfec311137393568a78804f7c
parentcc08d73612538545738d6fa5c339781e65896431 (diff)
downloadnixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.tar
nixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.tar.gz
nixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.tar.bz2
nixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.tar.lz
nixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.tar.xz
nixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.tar.zst
nixpkgs-d485da9d0034a72ceb9679c2ab0156c073f66b82.zip
zig_0_10: refactor
- 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
-rw-r--r--pkgs/development/compilers/zig/0.10.nix45
1 files changed, 25 insertions, 20 deletions
diff --git a/pkgs/development/compilers/zig/0.10.nix b/pkgs/development/compilers/zig/0.10.nix
index a6e253adde6..784cae916e3 100644
--- a/pkgs/development/compilers/zig/0.10.nix
+++ b/pkgs/development/compilers/zig/0.10.nix
@@ -8,18 +8,19 @@
 , zlib
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "zig";
   version = "0.10.1";
-  outputs = [ "out" "doc" ];
 
   src = fetchFromGitHub {
     owner = "ziglang";
-    repo = pname;
-    rev = version;
+    repo = "zig";
+    rev = finalAttrs.version;
     hash = "sha256-69QIkkKzApOGfrBdgtmxFMDytRkSh+0YiaJQPbXsBeo=";
   };
 
+  outputs = [ "out" "doc" ];
+
   nativeBuildInputs = [
     cmake
     llvmPackages.llvm.dev
@@ -41,14 +42,11 @@ stdenv.mkDerivation rec {
     ./zig_14559.patch
   ];
 
-  preBuild = ''
-    export HOME=$TMPDIR;
-  '';
-
+  # 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 = ''
-    # Zig's build looks at /usr/bin/env to find dynamic linking info. This
-    # doesn't work in Nix' sandbox. Use env from our coreutils instead.
-    substituteInPlace lib/std/zig/system/NativeTargetInfo.zig --replace "/usr/bin/env" "${coreutils}/bin/env"
+    substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
+      --replace "/usr/bin/env" "${coreutils}/bin/env"
   '';
 
   cmakeFlags = [
@@ -62,27 +60,34 @@ stdenv.mkDerivation rec {
     "-DZIG_TARGET_MCPU=baseline"
   ];
 
+  env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache";
+
   postBuild = ''
     ./zig2 build-exe ../doc/docgen.zig
     ./docgen ./zig2 ../doc/langref.html.in ./langref.html
   '';
 
-  doCheck = true;
-
   postInstall = ''
-    install -Dm644 -t $doc/share/doc/$pname-$version/html ./langref.html
+    install -Dm644 -t $doc/share/doc/zig-${finalAttrs.version}/html ./langref.html
   '';
 
+  doInstallCheck = true;
+
   installCheckPhase = ''
-    $out/bin/zig test --cache-dir "$TMPDIR" -I $src/test $src/test/behavior.zig
+    runHook preInstallCheck
+
+    $out/bin/zig test --cache-dir "$TMPDIR/cache-dir" -I $src/test $src/test/behavior.zig
+
+    runHook postInstallCheck
   '';
 
-  meta = with lib; {
+  meta = {
     homepage = "https://ziglang.org/";
     description =
       "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
-    license = licenses.mit;
-    maintainers = with maintainers; [ aiotter andrewrk AndersonTorres ];
-    platforms = platforms.unix;
+    changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ aiotter andrewrk AndersonTorres ];
+    platforms = lib.platforms.unix;
   };
-}
+})