forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
157 lines (152 loc) · 4.29 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nix-overlays.url = "github:anmonteiro/nix-overlays";
flake-utils.url = "github:numtide/flake-utils";
ocamllsp.url = "git+https://www.github.com/ocaml/ocaml-lsp?submodules=1";
opam-nix = {
url = "github:tweag/opam-nix";
inputs.opam-repository.follows = "opam-repository";
};
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
melange.url = "github:melange-re/melange";
};
outputs =
{ self
, flake-utils
, opam-nix
, nixpkgs
, ocamllsp
, opam-repository
, melange
, nix-overlays
}@inputs:
let package = "dune";
in flake-utils.lib.eachDefaultSystem (system:
let
devPackages = {
menhir = "*";
lwt = "*";
csexp = "*";
core_bench = "*";
js_of_ocaml = "*";
js_of_ocaml-compiler = "*";
mdx = "*";
odoc = "*";
ppx_expect = "*";
ppxlib = "*";
ctypes = "*";
utop = "*";
cinaps = "*";
ocamlfind = "1.9.2";
};
pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [
(self: super: {
ocamlPackages = self.ocaml-ng.ocamlPackages_4_14;
})
melange.overlays.default
];
ocamlformat =
let
ocamlformat_version =
let
lists = pkgs.lib.lists;
strings = pkgs.lib.strings;
ocamlformat_config = strings.splitString "\n" (builtins.readFile ./.ocamlformat);
prefix = "version=";
ocamlformat_version_pred = line: strings.hasPrefix prefix line;
version_line = lists.findFirst ocamlformat_version_pred "not_found" ocamlformat_config;
version = strings.removePrefix prefix version_line;
in
builtins.replaceStrings [ "." ] [ "_" ] version;
in
builtins.getAttr ("ocamlformat_" + ocamlformat_version) pkgs;
scope =
opam-nix.lib.${system}.buildOpamProject'
{
inherit pkgs;
repos = [ opam-repository ];
} ./.
(devPackages // {
ocaml-base-compiler = "4.14.0";
});
in
{
packages.default = scope.dune;
devShells.doc =
pkgs.mkShell {
buildInputs = (with pkgs;
[
sphinx
sphinx-autobuild
python310Packages.sphinx-copybutton
python310Packages.sphinx-rtd-theme
]
);
};
devShells.fmt =
pkgs.mkShell {
inputsFrom = [ pkgs.dune_3 ];
buildInputs = [ ocamlformat ];
};
devShells.slim =
let
pkgs = nix-overlays.legacyPackages.${system}.appendOverlays [
(self: super: {
ocamlPackages = self.ocaml-ng.ocamlPackages_4_14;
})
melange.overlays.default
];
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [ pkg-config nodejs-slim ];
inputsFrom = [ pkgs.ocamlPackages.dune_3 ];
buildInputs = with pkgs.ocamlPackages; [
merlin
ocamlformat
ppx_expect
ctypes
integers
mdx
cinaps
menhir
odoc
lwt
];
};
devShells.coq =
pkgs.mkShell {
inputsFrom = [ pkgs.dune_3 ];
buildInputs = with pkgs; [
coq_8_16
coq_8_16.ocamlPackages.findlib
];
};
devShells.default =
pkgs.mkShell {
nativeBuildInputs = [ pkgs.opam ];
buildInputs = (with pkgs;
[
# dev tools
ocamlformat
coq_8_16
nodejs-slim
patdiff
pkg-config
file
ccls
mercurial
] ++ (if stdenv.isLinux then [ strace ] else [ ]))
++ [
ocamllsp.outputs.packages.${system}.ocaml-lsp-server
pkgs.ocamlPackages.melange
pkgs.ocamlPackages.mel
]
++ nixpkgs.lib.attrsets.attrVals (builtins.attrNames devPackages) scope;
inputsFrom = [ self.packages.${system}.default ];
};
});
}