Skip to content

Commit 922a726

Browse files
authored
nix: export an overlay that adds ocaml-lsp itself to pkgs.ocamlPackages (#1231)
1 parent a74fb4a commit 922a726

File tree

1 file changed

+53
-41
lines changed

1 file changed

+53
-41
lines changed

flake.nix

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,58 @@
3434
stdune = osuper.stdune.overrideAttrs fixPreBuild;
3535
});
3636
};
37+
lspPackage = pkgs:
38+
with pkgs.ocamlPackages;
39+
buildDunePackage {
40+
pname = package;
41+
version = "n/a";
42+
src = ./.;
43+
duneVersion = "3";
44+
buildInputs = [
45+
ocamlc-loc
46+
astring
47+
camlp-streams
48+
dune-build-info
49+
re
50+
dune-rpc
51+
chrome-trace
52+
dyn
53+
fiber
54+
xdg
55+
ordering
56+
spawn
57+
pp
58+
csexp
59+
ocamlformat-rpc-lib
60+
stdune
61+
yojson
62+
ppx_yojson_conv_lib
63+
uutf
64+
merlin-lib
65+
];
66+
propagatedBuildInputs = [ ];
67+
doCheck = false;
68+
buildPhase = ''
69+
runHook preBuild
70+
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
71+
runHook postBuild
72+
'';
73+
meta = {
74+
mainProgram = "ocamllsp";
75+
};
76+
};
3777
in
38-
flake-utils.lib.eachDefaultSystem (system:
78+
{
79+
overlays.default = (final: prev: {
80+
ocamlPackages = prev.ocamlPackages.overrideScope (oself: osuper:
81+
with oself;
82+
83+
{
84+
ocaml-lsp = lspPackage final;
85+
}
86+
);
87+
});
88+
} // (flake-utils.lib.eachDefaultSystem (system:
3989
let
4090
pkgs = import nixpkgs { overlays = [ overlay ]; inherit system; };
4191
inherit (pkgs.ocamlPackages) buildDunePackage;
@@ -104,45 +154,7 @@
104154
packages =
105155
rec {
106156
# we have a package without opam2nix for easy consumption for nix users
107-
default = pkgs.ocamlPackages.buildDunePackage {
108-
pname = package;
109-
version = "n/a";
110-
src = ./.;
111-
duneVersion = "3";
112-
buildInputs = with pkgs.ocamlPackages; [
113-
ocamlc-loc
114-
astring
115-
camlp-streams
116-
dune-build-info
117-
re
118-
dune-rpc
119-
chrome-trace
120-
dyn
121-
fiber
122-
xdg
123-
ordering
124-
spawn
125-
pp
126-
csexp
127-
ocamlformat-rpc-lib
128-
stdune
129-
yojson
130-
ppx_yojson_conv_lib
131-
uutf
132-
lsp
133-
merlin-lib
134-
];
135-
propagatedBuildInputs = [ ];
136-
doCheck = false;
137-
buildPhase = ''
138-
runHook preBuild
139-
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
140-
runHook postBuild
141-
'';
142-
meta = {
143-
mainProgram = "ocamllsp";
144-
};
145-
};
157+
default = lspPackage pkgs;
146158

147159
ocaml-lsp = fast.ocaml-lsp;
148160
};
@@ -167,5 +179,5 @@
167179
buildInputs = [ pkgs.dune-release ];
168180
};
169181
};
170-
});
182+
}));
171183
}

0 commit comments

Comments
 (0)