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