2021-03-20 04:20:00 +00:00
|
|
|
{ lib
|
|
|
|
, substituteAll
|
|
|
|
, fetchurl
|
|
|
|
, ocaml
|
|
|
|
, dune_2
|
|
|
|
, buildDunePackage
|
|
|
|
, yojson
|
|
|
|
, csexp
|
2022-09-09 14:08:57 +00:00
|
|
|
, merlin-lib
|
2021-03-20 04:20:00 +00:00
|
|
|
, dot-merlin-reader
|
|
|
|
, jq
|
|
|
|
, menhir
|
2021-06-06 07:54:09 +00:00
|
|
|
, menhirLib
|
|
|
|
, menhirSdk
|
2021-03-20 04:20:00 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-09-09 14:08:57 +00:00
|
|
|
merlinVersion = "4.6";
|
2021-03-20 04:20:00 +00:00
|
|
|
|
|
|
|
hashes = {
|
2022-09-09 14:08:57 +00:00
|
|
|
"4.6-412" = "sha256-isiurLeWminJQQR4oHpJPCzVk6cEmtQdX4+n3Pdka5c=";
|
|
|
|
"4.6-413" = "sha256-8903H4TE6F/v2Kw1XpcpdXEiLIdb9llYgt42zSR9kO4=";
|
|
|
|
"4.6-414" = "sha256-AuvXCjx32JQBY9vkxAd0pEjtFF6oTgrT1f9TJEEDk84=";
|
2021-03-20 04:20:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ocamlVersionShorthand = lib.concatStrings
|
|
|
|
(lib.take 2 (lib.splitVersion ocaml.version));
|
|
|
|
|
|
|
|
version = "${merlinVersion}-${ocamlVersionShorthand}";
|
|
|
|
in
|
|
|
|
|
|
|
|
if !lib.hasAttr version hashes
|
|
|
|
then builtins.throw "merlin ${merlinVersion} is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
|
|
|
buildDunePackage {
|
|
|
|
pname = "merlin";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2021-12-06 16:07:01 +00:00
|
|
|
url = "https://github.com/ocaml/merlin/releases/download/v${version}/merlin-${version}.tbz";
|
2021-03-20 04:20:00 +00:00
|
|
|
sha256 = hashes."${version}";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./fix-paths.patch;
|
|
|
|
dot_merlin_reader = "${dot-merlin-reader}/bin/dot-merlin-reader";
|
|
|
|
dune = "${dune_2}/bin/dune";
|
|
|
|
})
|
2022-09-09 14:08:57 +00:00
|
|
|
];
|
2021-03-20 04:20:00 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
menhir
|
|
|
|
jq
|
|
|
|
];
|
2021-03-20 04:20:00 +00:00
|
|
|
buildInputs = [
|
|
|
|
dot-merlin-reader
|
|
|
|
yojson
|
2022-09-09 14:08:57 +00:00
|
|
|
(if lib.versionAtLeast version "4.6-414"
|
|
|
|
then merlin-lib
|
|
|
|
else csexp)
|
2022-03-05 16:20:37 +00:00
|
|
|
menhirSdk
|
|
|
|
menhirLib
|
2021-03-20 04:20:00 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
patchShebangs tests/merlin-wrapper
|
|
|
|
dune runtest # filtering with -p disables tests
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "An editor-independent tool to ease the development of programs in OCaml";
|
|
|
|
homepage = "https://github.com/ocaml/merlin";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ maintainers.vbgl maintainers.sternenseemann ];
|
|
|
|
};
|
|
|
|
}
|