From 0ee8802f859ff6d0e690618d0b172b209a845a47 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 1 Dec 2023 17:51:10 +0100 Subject: [PATCH] =?UTF-8?q?ocamlPackages.merlin:=204.12=20=E2=86=92=204.13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- pkgs/development/tools/ocaml/merlin/4.x.nix | 29 ++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pkgs/development/tools/ocaml/merlin/4.x.nix b/pkgs/development/tools/ocaml/merlin/4.x.nix index ef9330054f35..a5dec7993d84 100644 --- a/pkgs/development/tools/ocaml/merlin/4.x.nix +++ b/pkgs/development/tools/ocaml/merlin/4.x.nix @@ -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 {