Skip to content

Commit d485da9

Browse files
zig_0_10: refactor
- Use rec-less, overlay-style overridable recursive attributes (in effect since #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
1 parent cc08d73 commit d485da9

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

pkgs/development/compilers/zig/0.10.nix

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
, zlib
99
}:
1010

11-
stdenv.mkDerivation rec {
11+
stdenv.mkDerivation (finalAttrs: {
1212
pname = "zig";
1313
version = "0.10.1";
14-
outputs = [ "out" "doc" ];
1514

1615
src = fetchFromGitHub {
1716
owner = "ziglang";
18-
repo = pname;
19-
rev = version;
17+
repo = "zig";
18+
rev = finalAttrs.version;
2019
hash = "sha256-69QIkkKzApOGfrBdgtmxFMDytRkSh+0YiaJQPbXsBeo=";
2120
};
2221

22+
outputs = [ "out" "doc" ];
23+
2324
nativeBuildInputs = [
2425
cmake
2526
llvmPackages.llvm.dev
@@ -41,14 +42,11 @@ stdenv.mkDerivation rec {
4142
./zig_14559.patch
4243
];
4344

44-
preBuild = ''
45-
export HOME=$TMPDIR;
46-
'';
47-
45+
# Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
46+
# work in Nix's sandbox. Use env from our coreutils instead.
4847
postPatch = ''
49-
# Zig's build looks at /usr/bin/env to find dynamic linking info. This
50-
# doesn't work in Nix' sandbox. Use env from our coreutils instead.
51-
substituteInPlace lib/std/zig/system/NativeTargetInfo.zig --replace "/usr/bin/env" "${coreutils}/bin/env"
48+
substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
49+
--replace "/usr/bin/env" "${coreutils}/bin/env"
5250
'';
5351

5452
cmakeFlags = [
@@ -62,27 +60,34 @@ stdenv.mkDerivation rec {
6260
"-DZIG_TARGET_MCPU=baseline"
6361
];
6462

63+
env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache";
64+
6565
postBuild = ''
6666
./zig2 build-exe ../doc/docgen.zig
6767
./docgen ./zig2 ../doc/langref.html.in ./langref.html
6868
'';
6969

70-
doCheck = true;
71-
7270
postInstall = ''
73-
install -Dm644 -t $doc/share/doc/$pname-$version/html ./langref.html
71+
install -Dm644 -t $doc/share/doc/zig-${finalAttrs.version}/html ./langref.html
7472
'';
7573

74+
doInstallCheck = true;
75+
7676
installCheckPhase = ''
77-
$out/bin/zig test --cache-dir "$TMPDIR" -I $src/test $src/test/behavior.zig
77+
runHook preInstallCheck
78+
79+
$out/bin/zig test --cache-dir "$TMPDIR/cache-dir" -I $src/test $src/test/behavior.zig
80+
81+
runHook postInstallCheck
7882
'';
7983

80-
meta = with lib; {
84+
meta = {
8185
homepage = "https://ziglang.org/";
8286
description =
8387
"General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
84-
license = licenses.mit;
85-
maintainers = with maintainers; [ aiotter andrewrk AndersonTorres ];
86-
platforms = platforms.unix;
88+
changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html";
89+
license = lib.licenses.mit;
90+
maintainers = with lib.maintainers; [ aiotter andrewrk AndersonTorres ];
91+
platforms = lib.platforms.unix;
8792
};
88-
}
93+
})

0 commit comments

Comments
 (0)