-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
59 lines (50 loc) · 1.52 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
# nix build '.?submodules=1#'
# git submodule add https://github.com/username/repo-name.git path/to/submodule
# git clone [email protected]:Hejsil/zig-clap.git
# git submodule add [email protected]:Hejsil/zig-clap.git dependencies/zig-clap
{
description = "A flake for building and testing with Zig";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages.default = pkgs.stdenv.mkDerivation {
name = "zig-project";
src = self;
nativeBuildInputs = [ pkgs.zig ];
buildPhase = ''
# Resolves ReadOnly errors
export HOME=$TMPDIR
zig build
if [ ! -d zig-out/bin ]; then
echo "zig-out/bin directory not found. Build may have failed."
exit 1
fi
echo 'bin contents'
ls zig-out/bin/
echo 'bin contents printed'
'';
checkPhase = ''
zig build test --summary all --global-cache-dir $PWD/zig-cache --cache-dir $PWD/zig-cache --verbose
'';
installPhase = ''
mkdir -p $out/bin
cp -r zig-out/bin/* $out/bin/
'';
};
devShell = pkgs.mkShell { buildInputs = [ pkgs.zig ]; };
}
);
}