blob: 784cae916e346408e8820a28017ae245cbd25e77 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
{ lib
, stdenv
, fetchFromGitHub
, cmake
, coreutils
, llvmPackages
, libxml2
, zlib
}:
stdenv.mkDerivation (finalAttrs: {
pname = "zig";
version = "0.10.1";
src = fetchFromGitHub {
owner = "ziglang";
repo = "zig";
rev = finalAttrs.version;
hash = "sha256-69QIkkKzApOGfrBdgtmxFMDytRkSh+0YiaJQPbXsBeo=";
};
outputs = [ "out" "doc" ];
nativeBuildInputs = [
cmake
llvmPackages.llvm.dev
];
buildInputs = [
coreutils
libxml2
zlib
] ++ (with llvmPackages; [
libclang
lld
llvm
]);
patches = [
# Backport alignment related panics from zig-master to 0.10.
# Upstream issue: https://github.com/ziglang/zig/issues/14559
./zig_14559.patch
];
# 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 = ''
substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
--replace "/usr/bin/env" "${coreutils}/bin/env"
'';
cmakeFlags = [
# file RPATH_CHANGE could not write new RPATH
"-DCMAKE_SKIP_BUILD_RPATH=ON"
# always link against static build of LLVM
"-DZIG_STATIC_LLVM=ON"
# ensure determinism in the compiler build
"-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
'';
postInstall = ''
install -Dm644 -t $doc/share/doc/zig-${finalAttrs.version}/html ./langref.html
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/zig test --cache-dir "$TMPDIR/cache-dir" -I $src/test $src/test/behavior.zig
runHook postInstallCheck
'';
meta = {
homepage = "https://ziglang.org/";
description =
"General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
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;
};
})
|