summary refs log tree commit diff
path: root/pkgs/development/tools/ocaml/merlin/4.x.nix
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-03-18 17:15:41 +0100
committersterni <sternenseemann@systemli.org>2021-03-27 17:26:12 +0100
commitef6450411f1c924463508a6b01e36801784042f3 (patch)
treeaefec9b0263be86ffeeb35e060b62daff2841a43 /pkgs/development/tools/ocaml/merlin/4.x.nix
parent29d77c57edefc8412eb9abb23985d9371d409c76 (diff)
downloadnixpkgs-ef6450411f1c924463508a6b01e36801784042f3.tar
nixpkgs-ef6450411f1c924463508a6b01e36801784042f3.tar.gz
nixpkgs-ef6450411f1c924463508a6b01e36801784042f3.tar.bz2
nixpkgs-ef6450411f1c924463508a6b01e36801784042f3.tar.lz
nixpkgs-ef6450411f1c924463508a6b01e36801784042f3.tar.xz
nixpkgs-ef6450411f1c924463508a6b01e36801784042f3.tar.zst
nixpkgs-ef6450411f1c924463508a6b01e36801784042f3.zip
ocamlPackages_4_{11,12}: merlin: 3.4.2 -> 4.1
Add nix expression for the OCaml-version specific versions of merlin
4.1 and conditionally call it in ocaml-packages.nix.
Diffstat (limited to 'pkgs/development/tools/ocaml/merlin/4.x.nix')
-rw-r--r--pkgs/development/tools/ocaml/merlin/4.x.nix77
1 files changed, 77 insertions, 0 deletions
diff --git a/pkgs/development/tools/ocaml/merlin/4.x.nix b/pkgs/development/tools/ocaml/merlin/4.x.nix
new file mode 100644
index 00000000000..77595169565
--- /dev/null
+++ b/pkgs/development/tools/ocaml/merlin/4.x.nix
@@ -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 ];
+  };
+}