depot/third_party/nixpkgs/pkgs/development/ocaml-modules/ocaml-lsp/default.nix
Default email f34ce41345 Project import generated by Copybara.
GitOrigin-RevId: b73c2221a46c13557b1b3be9c2070cc42cf01eb3
2024-07-27 08:49:29 +02:00

50 lines
1.1 KiB
Nix

{ lib
, ocaml
, buildDunePackage
, lsp
, xdg
, re
, fiber
, makeWrapper
, dot-merlin-reader
, spawn
, ocamlc-loc
, merlin-lib
, astring
, camlp-streams
, base
}:
# Freeze ocaml-lsp-version at 1.17.0 for OCaml 5.0
# for which merlin 4.16 is not available
let lsp_v =
if lib.versions.majorMinor ocaml.version == "5.0"
then lsp.override { version = "1.17.0"; }
else lsp
; in
let lsp = lsp_v; in
buildDunePackage rec {
pname = "ocaml-lsp-server";
inherit (lsp) version src preBuild;
buildInputs = lsp.buildInputs ++ [ lsp re ]
++ lib.optional (lib.versionAtLeast version "1.9") spawn
++ lib.optionals (lib.versionAtLeast version "1.10") [ fiber xdg ]
++ lib.optional (lib.versionAtLeast version "1.14.2") ocamlc-loc
++ lib.optionals (lib.versionAtLeast version "1.17.0") [ astring camlp-streams merlin-lib ]
++ lib.optional (lib.versionAtLeast version "1.18.0") base
;
nativeBuildInputs = [ makeWrapper ];
postInstall = ''
wrapProgram $out/bin/ocamllsp --prefix PATH : ${dot-merlin-reader}/bin
'';
meta = lsp.meta // {
description = "OCaml Language Server Protocol implementation";
mainProgram = "ocamllsp";
};
}