From ab255a671aa6b5d390e37425fc3ed6f93564b71d Mon Sep 17 00:00:00 2001 From: Pierre Roux Date: Fri, 17 Jan 2025 11:02:29 +0100 Subject: [PATCH] coqPackages.coq-elpi: enable to override ocamlPackages.elpi version --- .../coq-modules/coq-elpi/default.nix | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/pkgs/development/coq-modules/coq-elpi/default.nix b/pkgs/development/coq-modules/coq-elpi/default.nix index eeb00f37b804e..18e83c48b1a4e 100644 --- a/pkgs/development/coq-modules/coq-elpi/default.nix +++ b/pkgs/development/coq-modules/coq-elpi/default.nix @@ -5,25 +5,30 @@ coq, stdlib, version ? null, + elpi-version ? null, }: let - elpi = coq.ocamlPackages.elpi.override ( - lib.switch coq.coq-version [ - { case = "8.11"; out = { version = "1.11.4"; }; } - { case = "8.12"; out = { version = "1.12.0"; }; } - { case = "8.13"; out = { version = "1.13.7"; }; } - { case = "8.14"; out = { version = "1.13.7"; }; } - { case = "8.15"; out = { version = "1.15.0"; }; } - { case = "8.16"; out = { version = "1.17.0"; }; } - { case = "8.17"; out = { version = "1.17.0"; }; } - { case = "8.18"; out = { version = "1.18.1"; }; } - { case = "8.19"; out = { version = "1.18.1"; }; } - { case = "8.20"; out = { version = "1.19.2"; }; } - ] { } - ); -in -(mkCoqDerivation { +default-elpi-version = if elpi-version != null then elpi-version else ( + lib.switch coq.coq-version [ + { case = "8.11"; out = "1.11.4"; } + { case = "8.12"; out = "1.12.0"; } + { case = "8.13"; out = "1.13.7"; } + { case = "8.14"; out = "1.13.7"; } + { case = "8.15"; out = "1.15.0"; } + { case = "8.16"; out = "1.17.0"; } + { case = "8.17"; out = "1.17.0"; } + { case = "8.18"; out = "1.18.1"; } + { case = "8.19"; out = "1.18.1"; } + { case = "8.20"; out = "1.19.2"; } + ] { } +); +elpi = coq.ocamlPackages.elpi.override { version = default-elpi-version; }; +propagatedBuildInputs_wo_elpi = [ + coq.ocamlPackages.findlib + stdlib +]; +derivation = mkCoqDerivation { pname = "elpi"; repo = "coq-elpi"; owner = "LPCIC"; @@ -81,11 +86,8 @@ in mlPlugin = true; useDuneifVersion = v: lib.versions.isGe "2.2.0" v || v == "dev"; - propagatedBuildInputs = [ - coq.ocamlPackages.findlib - elpi - stdlib - ]; + + propagatedBuildInputs = propagatedBuildInputs_wo_elpi ++ [ elpi ]; preConfigure = '' make elpi/dune || true @@ -96,11 +98,23 @@ in maintainers = [ lib.maintainers.cohencyril ]; license = lib.licenses.lgpl21Plus; }; -}).overrideAttrs +}; +patched-derivation1 = derivation.overrideAttrs + ( + o: + lib.optionalAttrs (o ? elpi-version) + { + propagatedBuildInputs = propagatedBuildInputs_wo_elpi ++ [ + (coq.ocamlPackages.elpi.override { version = o.elpi-version; }) + ]; + } + ); +patched-derivation2 = patched-derivation1.overrideAttrs ( o: lib.optionalAttrs (o.version != null && (o.version == "dev" || lib.versions.isGe "2.2.0" o.version)) { propagatedBuildInputs = o.propagatedBuildInputs ++ [ coq.ocamlPackages.ppx_optcomp ]; } - ) + ); +in patched-derivation2