Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
72 lines (67 loc) · 1.92 KB
/
Copy pathflake.nix
File metadata and controls
72 lines (67 loc) · 1.92 KB
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
{
description = "Zig implementation of Lox, from the book Crafting Interpreters";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
forAllSystems =
mkOutputs:
nixpkgs.lib.genAttrs [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
] (system: mkOutputs system nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (
system: pkgs: {
zlox = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "zlox";
version = "0.0.1";
src = nixpkgs.lib.cleanSource ./.;
nativeBuildInputs = [ pkgs.zig ];
meta.mainProgram = "zlox";
doCheck = true;
zigDeps = pkgs.zig_0_16.fetchDeps {
inherit (finalAttrs) src pname version;
hash = "sha256-cX1Ev7h7IpXN9q7/58Rqs2q4Mz8M2BtLYLSXjjpmcOc=";
};
postConfigure = ''
ln -s ${finalAttrs.zigDeps} "$ZIG_GLOBAL_CACHE_DIR/p"
'';
});
default = self.packages.${system}.zlox;
}
);
checks = forAllSystems (
system: pkgs: {
default = pkgs.runCommand "zlox-test" { } ''
echo 'print "hello" + " " + "world";' | ${
self.packages.${system}.default
}/bin/zlox 2>&1| grep 'hello world'
touch $out
'';
}
);
apps = forAllSystems (
system: pkgs: {
zlox = {
type = "app";
program = pkgs.lib.getExe self.packages.${system}.zlox;
};
default = self.apps.${system}.zlox;
}
);
devShells = forAllSystems (
_: pkgs: {
default = pkgs.mkShell {
packages = [
pkgs.zig_0_16
pkgs.zls_0_16
];
};
}
);
};
}