1{ lib, fetchzip, mkCoqDerivation, coq, version ? null }:
2
3let
4 ocamlPackages =
5 coq.ocamlPackages.overrideScope'
6 (self: super: {
7 ppxlib = super.ppxlib.override { version = "0.15.0"; };
8 # the following does not work
9 ppx_sexp_conv = super.ppx_sexp_conv.overrideAttrs (_: {
10 src = fetchzip {
11 url = "https://github.com/janestreet/ppx_sexp_conv/archive/v0.14.1.tar.gz";
12 sha256 = "04bx5id99clrgvkg122nx03zig1m7igg75piphhyx04w33shgkz2";
13 };
14 });
15 });
16
17 release = {
18 "8.14+rc1+0.14.0".sha256 = "1w7d7anvcfx8vz51mnrf1jkw6rlpzjkjlr06avf58wlhymww7pja";
19 "8.13.0+0.13.0".sha256 = "0k69907xn4k61w4mkhwf8kh8drw9pijk9ynijsppihw98j8w38fy";
20 "8.12.0+0.12.1".sha256 = "048x3sgcq4h845hi6hm4j4dsfca8zfj70dm42w68n63qcm6xf9hn";
21 "8.11.0+0.11.1".sha256 = "1phmh99yqv71vlwklqgfxiq2vj99zrzxmryj2j4qvg5vav3y3y6c";
22 "8.10.0+0.7.2".sha256 = "1ljzm63hpd0ksvkyxcbh8rdf7p90vg91gb4h0zz0941v1zh40k8c";
23 };
24in
25
26(with lib; mkCoqDerivation rec {
27 pname = "serapi";
28 inherit version release;
29
30 defaultVersion = with versions; switch coq.version [
31 { case = isEq "8.14"; out = "8.14+rc1+0.14.0"; }
32 { case = isEq "8.13"; out = "8.13.0+0.13.0"; }
33 { case = isEq "8.12"; out = "8.12.0+0.12.1"; }
34 { case = isEq "8.11"; out = "8.11.0+0.11.1"; }
35 { case = isEq "8.10"; out = "8.10.0+0.7.2"; }
36 ] null;
37
38 useDune2 = true;
39
40 propagatedBuildInputs =
41 with ocamlPackages; [
42 cmdliner
43 findlib # run time dependency of SerAPI
44 ppx_deriving
45 ppx_deriving_yojson
46 ppx_import
47 ppx_sexp_conv
48 sexplib
49 yojson
50 zarith # needed because of Coq
51 ];
52
53 installPhase = ''
54 runHook preInstall
55 dune install --prefix $out --libdir $OCAMLFIND_DESTDIR coq-serapi
56 runHook postInstall
57 '';
58
59 meta = with lib; {
60 homepage = "https://github.com/ejgallego/coq-serapi";
61 description = "SerAPI is a library for machine-to-machine interaction with the Coq proof assistant";
62 license = licenses.lgpl21Plus;
63 maintainers = [ maintainers.Zimmi48 ];
64 };
65}).overrideAttrs(o:
66 let inherit (o) version; in {
67 src = fetchzip {
68 url =
69 if version == "8.14+rc1+0.14.0"
70 then "https://github.com/ejgallego/coq-serapi/archive/refs/tags/8.14+rc1+0.14.0.tar.gz"
71 else
72 "https://github.com/ejgallego/coq-serapi/releases/download/${version}/coq-serapi-${
73 if version == "8.11.0+0.11.1" then version
74 else builtins.replaceStrings [ "+" ] [ "." ] version
75 }.tbz";
76 sha256 = release."${version}".sha256;
77 };
78
79 patches =
80 if version == "8.10.0+0.7.2"
81 then [
82 ./8.10.0+0.7.2.patch
83 ]
84 else if version == "8.11.0+0.11.1"
85 then [
86 ./8.11.0+0.11.1.patch
87 ]
88 else if version == "8.12.0+0.12.1" || version == "8.13.0+0.13.0"
89 then [
90 ./8.12.0+0.12.1.patch
91 ]
92 else [];
93})