ocamlPackages.merlin: 4.12 → 4.13

The range of supported versions of OCaml for each versions of Merlin is
no longer monotonic and can't be expressed with `lib.versionAtLeast`
easily.
The latest version of Merlin is now explicitly mapped for each version
of OCaml.
This commit is contained in:
Jules Aguillon 2023-12-01 17:51:10 +01:00
parent 475653dc2f
commit 0ee8802f85

View File

@ -15,7 +15,18 @@
}:
let
merlinVersion = if lib.versionAtLeast ocaml.version "4.14" then "4.12" else "4.7";
# Each releases of Merlin support a limited range of versions of OCaml.
merlinVersions = {
"4.12.0" = "4.7-412";
"4.12.1" = "4.7-412";
"4.13.0" = "4.7-413";
"4.13.1" = "4.7-413";
"4.14.0" = "4.13-414";
"4.14.1" = "4.13-414";
"5.0.0" = "4.12-500";
"5.1.0" = "4.13-501";
# "5.1.1" = "4.13.1-501";
};
hashes = {
"4.7-412" = "sha256-0U3Ia7EblKULNy8AuXFVKACZvGN0arYJv7BWiBRgT0Y=";
@ -29,21 +40,15 @@ let
"4.12-414" = "sha256-tgMUT4KyFeJubYVY1Sdv9ZvPB1JwcqEGcCuwuMqXHRQ=";
"4.12-500" = "sha256-j49R7KVzNKlXDL7WibTHxPG4VSOVv0uaz5/yMZZjkH8=";
"4.12-501" = "sha256-zMwzI1SXQDWQ9PaKL4o3J6JlRjmEs7lkXrwauy+QiMA=";
"4.13-414" = "sha256-AlzxqTuh5AkW9dnPIv51abv7r0A/VOS3JOT5IHix2wM=";
"4.13-501" = "sha256-G/VrI+qBVj2wxuB2qE9P1M73IvDmqmTrBFAA6mp+NRE=";
};
ocamlVersionShorthand =
let
v = lib.splitVersion ocaml.version;
major = builtins.elemAt v 0;
minor = builtins.elemAt v 1;
minor_prefix = if builtins.stringLength minor < 2 then "0" else "";
in "${toString major}${minor_prefix}${toString minor}";
version = "${merlinVersion}-${ocamlVersionShorthand}";
version = lib.getAttr ocaml.version merlinVersions;
in
if !lib.hasAttr version hashes
then builtins.throw "merlin ${merlinVersion} is not available for OCaml ${ocaml.version}"
if !lib.hasAttr ocaml.version merlinVersions
then builtins.throw "merlin is not available for OCaml ${ocaml.version}"
else
buildDunePackage {