1{
2 lib,
3 fetchurl,
4 buildDunePackage,
5 ocaml,
6 findlib,
7 cppo,
8 ppxlib,
9 ppx_derivers,
10 result,
11 ounit,
12 ounit2,
13 ocaml-migrate-parsetree,
14 version ?
15 if lib.versionAtLeast ppxlib.version "0.36" then
16 "6.1.1"
17 else if lib.versionAtLeast ppxlib.version "0.32" then
18 "6.0.3"
19 else if lib.versionAtLeast ppxlib.version "0.20" then
20 "5.2.1"
21 else if lib.versionAtLeast ppxlib.version "0.15" then
22 "5.1"
23 else
24 "5.0",
25}:
26
27let
28 hash =
29 {
30 "6.1.1" = "sha256-yR0epeFeaSii+JR9vRNbn3ZcwOLXK+JxQnmBr801DCQ=";
31 "6.0.3" = "sha256-N0qpezLF4BwJqXgQpIv6IYwhO1tknkRSEBRVrBnJSm0=";
32 "5.2.1" = "sha256:11h75dsbv3rs03pl67hdd3lbim7wjzh257ij9c75fcknbfr5ysz9";
33 "5.1" = "sha256:1i64fd7qrfzbam5hfbl01r0sx4iihsahcwqj13smmrjlnwi3nkxh";
34 "5.0" = "sha256:0fkzrn4pdyvf1kl0nwvhqidq01pnq3ql8zk1jd56hb0cxaw851w3";
35 }
36 ."${version}";
37in
38
39buildDunePackage rec {
40 pname = "ppx_deriving";
41 inherit version;
42
43 src = fetchurl {
44 url = "https://github.com/ocaml-ppx/ppx_deriving/releases/download/v${version}/ppx_deriving-${lib.optionalString (lib.versionOlder version "6.0") "v"}${version}.${
45 if lib.versionAtLeast version "6.1.1" then "tar.gz" else "tbz"
46 }";
47 inherit hash;
48 };
49
50 strictDeps = true;
51
52 nativeBuildInputs = [ cppo ];
53 buildInputs = [
54 findlib
55 ];
56 propagatedBuildInputs =
57 lib.optional (lib.versionOlder version "5.2") ocaml-migrate-parsetree
58 ++ [
59 ppx_derivers
60 ppxlib
61 ]
62 ++ lib.optional (lib.versionOlder version "6.0") result;
63
64 doCheck = lib.versionAtLeast ocaml.version "4.08";
65 checkInputs = [
66 (if lib.versionAtLeast version "5.2" then ounit2 else ounit)
67 ];
68
69 meta = with lib; {
70 description = "Library simplifying type-driven code generation on OCaml >=4.02";
71 maintainers = [ maintainers.maurer ];
72 license = licenses.mit;
73 };
74}