8
8
, zlib
9
9
} :
10
10
11
- stdenv . mkDerivation rec {
11
+ stdenv . mkDerivation ( finalAttrs : {
12
12
pname = "zig" ;
13
13
version = "0.10.1" ;
14
- outputs = [ "out" "doc" ] ;
15
14
16
15
src = fetchFromGitHub {
17
16
owner = "ziglang" ;
18
- repo = pname ;
19
- rev = version ;
17
+ repo = "zig" ;
18
+ rev = finalAttrs . version ;
20
19
hash = "sha256-69QIkkKzApOGfrBdgtmxFMDytRkSh+0YiaJQPbXsBeo=" ;
21
20
} ;
22
21
22
+ outputs = [ "out" "doc" ] ;
23
+
23
24
nativeBuildInputs = [
24
25
cmake
25
26
llvmPackages . llvm . dev
@@ -41,14 +42,11 @@ stdenv.mkDerivation rec {
41
42
./zig_14559.patch
42
43
] ;
43
44
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.
48
47
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"
52
50
'' ;
53
51
54
52
cmakeFlags = [
@@ -62,27 +60,34 @@ stdenv.mkDerivation rec {
62
60
"-DZIG_TARGET_MCPU=baseline"
63
61
] ;
64
62
63
+ env . ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache" ;
64
+
65
65
postBuild = ''
66
66
./zig2 build-exe ../doc/docgen.zig
67
67
./docgen ./zig2 ../doc/langref.html.in ./langref.html
68
68
'' ;
69
69
70
- doCheck = true ;
71
-
72
70
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
74
72
'' ;
75
73
74
+ doInstallCheck = true ;
75
+
76
76
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
78
82
'' ;
79
83
80
- meta = with lib ; {
84
+ meta = {
81
85
homepage = "https://ziglang.org/" ;
82
86
description =
83
87
"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 ;
87
92
} ;
88
- }
93
+ } )
0 commit comments