This repository was archived by the owner on Sep 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
124 lines (115 loc) · 3.19 KB
/
flake.nix
File metadata and controls
124 lines (115 loc) · 3.19 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
ocaml-overlay.url = "github:nix-ocaml/nix-overlays";
ocaml-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
treefmt-nix,
ocaml-overlay,
systems,
}:
let
lib = nixpkgs.lib;
lang-name = "parrot";
eachSystem =
f:
nixpkgs.lib.genAttrs (import systems) (
system:
f (
import nixpkgs {
inherit system;
overlays = [ ocaml-overlay.overlays.default ];
}
)
);
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in
{
packages = eachSystem (pkgs: {
default = pkgs.ocamlPackages.buildDunePackage {
pname = lang-name;
version = "0.1.0";
src = ./.;
buildInputs = with pkgs.ocamlPackages; [
extlib
bisect_ppx
ounit2
ppxlib
qcheck
menhir
ppx_variants_conv
ppx_deriving
visitors
zarith
];
preBuild = ''
export DUNE_CACHE=disabled
'';
};
});
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
checks = eachSystem (pkgs: {
project =
let
patchDuneCommand =
let
subcmds = [
"build"
"test"
"runtest"
"install"
];
in
lib.replaceStrings (lib.lists.map (subcmd: "dune ${subcmd}") subcmds) (
lib.lists.map (subcmd: "dune ${subcmd} --display=short") subcmds
);
in
self.packages.${pkgs.system}.default.overrideAttrs (oldAttrs: {
name = "check-${oldAttrs.name}";
doCheck = true;
buildPhase = patchDuneCommand oldAttrs.buildPhase;
checkPhase = patchDuneCommand oldAttrs.checkPhase;
# installPhase = patchDuneCommand oldAttrs.checkPhase;
});
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {
packages =
[
treefmtEval.${pkgs.system}.config.build.wrapper
]
++ (with pkgs; [
fswatch
ocaml
dune_3
nasm
clang
lldb
git # ari's computer is stupid
zig
])
++ (with pkgs.ocamlPackages; [
findlib
utop
odoc
ocamlformat
ocamlbuild
ocaml-lsp
merlin
])
# todo: this should still work on x86_64-darwin
++ (lib.optionals pkgs.stdenv.isLinux [ pkgs.valgrind ]);
inputsFrom = [
self.packages.${pkgs.system}.default
];
};
});
};
}