forked from ocaml/ocaml-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
81 lines (79 loc) · 2.48 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.follows = "opam-nix/nixpkgs";
opam-nix = {
url = "github:tweag/opam-nix";
inputs.opam-repository.follows = "opam-repository";
};
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
git-subrepo-src = {
url =
"github:rgrinberg/git-subrepo?rev=8fb6be3fb1500ab845081fc26ecdb950e9c0438c";
flake = false;
};
};
outputs = { self, flake-utils, opam-nix, nixpkgs, ... }@inputs:
let package = "ocaml-lsp-server";
in flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
localPackages = {
jsonrpc = "*";
lsp = "*";
ocaml-lsp-server = "*";
};
devPackages = {
menhir = "*";
ppx_yojson_conv = "*";
cinaps = "*";
ppx_expect = "*";
ocamlformat-rpc = "*";
ocamlfind = "1.9.2";
};
packagesFromNames = set:
(builtins.map (s: builtins.getAttr s scope)
(builtins.attrNames set));
allPackages = localPackages // devPackages;
scope =
(
let
scope =
on.buildOpamProject { resolveArgs = { with-test = true; }; } package
./.
(allPackages);
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;
});
git-subrepo = prev.git-subrepo.overrideAttr
(old: { src = inputs.git-subrepo-src; });
};
in
scope.overrideScope' overlay
);
in
{
packages =
(nixpkgs.lib.filterAttrs (name: value: builtins.hasAttr name localPackages) scope) //
{ default = self.packages.${system}.${package}; };
devShell =
pkgs.mkShell {
buildInputs = (with pkgs;
[
# dev tools
git-subrepo
ocamlformat_0_21_0
yarn
]) ++ packagesFromNames devPackages;
inputsFrom = [ self.packages.${system}.default ]
++ packagesFromNames localPackages;
};
});
}