forked from ocaml/ocaml-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
121 lines (119 loc) · 3.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
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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
opam-nix = {
url = "github:tweag/opam-nix";
inputs.opam-repository.follows = "opam-repository";
};
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
};
outputs = { self, flake-utils, opam-nix, opam-repository, nixpkgs, ... }@inputs:
let
package = "ocaml-lsp-server";
overlay = final: prev: {
${package} = prev.${package}.overrideAttrs (_: {
# Do not add share/nix-support, so that dependencies from
# the scope don't leak into dependent derivations
doNixSupport = false;
});
dune-release = prev.dune-release.overrideAttrs (_: {
doCheck = false;
});
};
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { overlays = [ overlay ]; inherit system; };
on = opam-nix.lib.${system};
localPackages = {
jsonrpc = "*";
lsp = "*";
ocaml-lsp-server = "*";
};
devPackages = {
menhir = "*";
ppx_yojson_conv = "*";
cinaps = "*";
ppx_expect = "*";
ocamlfind = "1.9.2";
};
packagesFromNames = set:
(builtins.map (s: builtins.getAttr s scope)
(builtins.attrNames set));
allPackages = localPackages // devPackages;
scope =
(
let
scope =
on.buildOpamProject
{
repos = [ opam-repository ];
inherit pkgs;
resolveArgs = { with-test = true; };
}
package
./.
(allPackages);
in
scope.overrideScope' overlay
);
opam2nixPackages = nixpkgs.lib.filterAttrs (name: value: builtins.hasAttr name localPackages) scope;
in
{
packages =
opam2nixPackages //
{
# we have a package without opam2nix for easy consumption for nix users
default = pkgs.ocamlPackages.buildDunePackage {
pname = package;
version = "n/a";
src = ./.;
duneVersion = "3";
buildInputs = with pkgs.ocamlPackages; [
ocamlc-loc
omd
octavius
dune-build-info
re
dune-rpc
chrome-trace
dyn
fiber
xdg
ordering
spawn
pp
csexp
ocamlformat-rpc-lib
stdune
yojson
ppx_yojson_conv_lib
uutf
lsp
];
propagatedBuildInputs = [ ];
doCheck = false;
buildPhase = ''
runHook preBuild
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
};
};
devShell =
pkgs.mkShell {
buildInputs = (with pkgs;
[
# dev tools
ocamlformat_0_24_1
yarn
dune-release
]) ++ packagesFromNames devPackages;
inputsFrom = packagesFromNames opam2nixPackages;
};
});
}