Skip to content

Commit

Permalink
ocamlPackages_4_{11,12}: merlin: 3.4.2 -> 4.1
Browse files Browse the repository at this point in the history
Add nix expression for the OCaml-version specific versions of merlin
4.1 and conditionally call it in ocaml-packages.nix.
  • Loading branch information
sternenseemann committed Mar 27, 2021
1 parent 29d77c5 commit ef64504
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
77 changes: 77 additions & 0 deletions pkgs/development/tools/ocaml/merlin/4.x.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{ lib
, substituteAll
, fetchurl
, ocaml
, dune_2
, buildDunePackage
, yojson
, csexp
, result
, dot-merlin-reader
, jq
, menhir
}:

let
merlinVersion = "4.1";

hashes = {
"4.1-411" = "9e2e6fc799c93ce1f2c7181645eafa37f64e43ace062b69218e1c29ac459937d";
"4.1-412" = "fb4caede73bdb8393bd60e31792af74b901ae2d319ac2f2a2252c694d2069d8d";
};

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 {
url = "https://github.com/ocaml/merlin/releases/download/v${version}/merlin-v${version}.tbz";
sha256 = hashes."${version}";
};

patches = [
(substituteAll {
src = ./fix-paths.patch;
dot_merlin_reader = "${dot-merlin-reader}/bin/dot-merlin-reader";
dune = "${dune_2}/bin/dune";
})
];

useDune2 = true;

buildInputs = [
dot-merlin-reader
yojson
csexp
result
];

doCheck = true;
checkPhase = ''
runHook preCheck
patchShebangs tests/merlin-wrapper
dune runtest # filtering with -p disables tests
runHook postCheck
'';
checkInputs = [
jq
menhir
];

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 ];
};
}
5 changes: 4 additions & 1 deletion pkgs/top-level/ocaml-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ let

menhir = callPackage ../development/ocaml-modules/menhir { };

merlin = callPackage ../development/tools/ocaml/merlin { };
merlin =
if lib.versionAtLeast ocaml.version "4.11"
then callPackage ../development/tools/ocaml/merlin/4.x.nix { }
else callPackage ../development/tools/ocaml/merlin { };

merlin-extend = callPackage ../development/ocaml-modules/merlin-extend { };

Expand Down

0 comments on commit ef64504

Please sign in to comment.