Skip to content

Commit 615b79f

Browse files
authored
chore(nix): remove some duplication (#1251)
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
1 parent 1ff28f4 commit 615b79f

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

flake.nix

+13-20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
outputs = { self, flake-utils, nixpkgs, ... }@inputs:
88
let
99
package = "ocaml-lsp-server";
10+
basePackage = {
11+
duneVersion = "3";
12+
version = "n/a";
13+
src = ./.;
14+
};
1015
overlay = final: prev: {
1116
${package} = prev.${package}.overrideAttrs (_: {
1217
# Do not add share/nix-support, so that dependencies from
@@ -36,11 +41,8 @@
3641
};
3742
lspPackage = pkgs:
3843
with pkgs.ocamlPackages;
39-
buildDunePackage {
44+
buildDunePackage (basePackage // {
4045
pname = package;
41-
version = "n/a";
42-
src = ./.;
43-
duneVersion = "3";
4446
buildInputs = [
4547
ocamlc-loc
4648
astring
@@ -73,7 +75,7 @@
7375
meta = {
7476
mainProgram = "ocamllsp";
7577
};
76-
};
78+
});
7779
in
7880
{
7981
overlays.default = (final: prev: {
@@ -91,20 +93,14 @@
9193
inherit (pkgs.ocamlPackages) buildDunePackage;
9294
fast = rec {
9395

94-
jsonrpc = buildDunePackage {
96+
jsonrpc = buildDunePackage (basePackage // {
9597
pname = "jsonrpc";
96-
version = "n/a";
97-
src = ./.;
98-
duneVersion = "3";
9998
propagatedBuildInputs = with pkgs.ocamlPackages; [ ];
10099
doCheck = false;
101-
};
100+
});
102101

103-
lsp = buildDunePackage {
102+
lsp = buildDunePackage (basePackage // {
104103
pname = "lsp";
105-
version = "n/a";
106-
src = ./.;
107-
duneVersion = "3";
108104
propagatedBuildInputs = with pkgs.ocamlPackages; [
109105
jsonrpc
110106
yojson
@@ -113,13 +109,10 @@
113109
];
114110
checkInputs = with pkgs.ocamlPackages; [ cinaps ppx_expect ];
115111
doCheck = false;
116-
};
112+
});
117113

118-
ocaml-lsp = buildDunePackage {
114+
ocaml-lsp = buildDunePackage (basePackage // {
119115
pname = "ocaml-lsp";
120-
version = "n/a";
121-
src = ./.;
122-
duneVersion = "3";
123116
checkInputs = with pkgs.ocamlPackages; [ ppx_expect ];
124117
propagatedBuildInputs = with pkgs.ocamlPackages; [
125118
ocamlc-loc
@@ -146,7 +139,7 @@
146139
merlin-lib
147140
];
148141
doCheck = false;
149-
};
142+
});
150143
};
151144
in
152145
{

0 commit comments

Comments
 (0)