This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
forked from ziglang/zig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
102 lines (88 loc) · 2.38 KB
/
flake.nix
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
94
95
96
97
98
99
100
101
102
{
description = "Zig compiler development.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Used for shell.nix
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
let
zigOverlay = f: p: {
zig = p.stdenv.mkDerivation {
pname = "zig";
version = "0.12.0-dev.${self.shortRev or "dirty"}";
src = p.lib.cleanSource self;
nativeBuildInputs = [
p.cmake
p.llvmPackages_17.llvm.dev
];
buildInputs = [
p.stdenv.cc.cc.lib
p.stdenv.cc.cc.libc_dev.out
p.libxml2
p.zlib
] ++ (with p.llvmPackages_17; [
libclang
lld
llvm
]);
env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache";
postPatch = ''
substituteInPlace lib/std/zig/system.zig \
--replace "/usr/bin/env" "${p.coreutils}/bin/env"
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/zig test --cache-dir "$TMPDIR/zig-test-cache" -I $src/test $src/test/behavior.zig
runHook postInstallCheck
'';
};
};
in
(flake-utils.lib.eachSystem flake-utils.lib.allSystems (
system: let
pkgs = (import nixpkgs {inherit system;}).appendOverlays [
zigOverlay
];
llvmPackages = pkgs.llvmPackages_17;
in {
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs;
[
stdenv.cc.cc.lib
stdenv.cc.cc.libc_dev.out
cmake
gdb
libxml2
ninja
qemu
wasmtime
zlib
]
++ (with llvmPackages; [
clang
clang-unwrapped
lld
llvm
]);
hardeningDisable = ["all"];
};
packages.default = pkgs.zig;
legacyPackages = pkgs;
# For compatibility with older versions of the `nix` binary
devShell = self.devShells.${system}.default;
}
)) // {
overlays.default = zigOverlay;
};
}