1{ lib, stdenv, fetchFromGitHub, buildDunePackage, ocaml, findlib, cppo }:
2
3if lib.versionAtLeast ocaml.version "5.2"
4then throw "ppx_tools is not available for OCaml ${ocaml.version}"
5else
6
7let param =
8 let v6_6 = {
9 version = "6.6";
10 sha256 = "sha256-QhuaQ9346a3neoRM4GrOVzjR8fg9ysMZR1VzNgyIQtc=";
11 nativeBuildInputs = [cppo];
12 buildInputs = [cppo];
13 }; in
14{
15 "4.02" = {
16 version = "5.0+4.02.0";
17 sha256 = "16drjk0qafjls8blng69qiv35a84wlafpk16grrg2i3x19p8dlj8"; };
18 "4.03" = {
19 version = "5.0+4.03.0";
20 sha256 = "061v1fl5z7z3ywi4ppryrlcywnvnqbsw83ppq72qmkc7ma4603jg"; };
21 "4.04" = {
22 version = "unstable-20161114";
23 rev = "49c08e2e4ea8fef88692cd1dcc1b38a9133f17ac";
24 sha256 = "0ywzfkf5brj33nwh49k9if8x8v433ral25f3nbklfc9vqr06zrfl"; };
25 "4.05" = {
26 version = "5.0+4.05.0";
27 sha256 = "1jvvhk6wnkvm7b9zph309ihsc0hyxfpahmxxrq19vx8c674jsdm4"; };
28 "4.06" = {
29 version = "5.1+4.06.0";
30 sha256 = "1ww4cspdpgjjsgiv71s0im5yjkr3544x96wsq1vpdacq7dr7zwiw"; };
31 "4.07" = {
32 version = "5.1+4.06.0";
33 sha256 = "1ww4cspdpgjjsgiv71s0im5yjkr3544x96wsq1vpdacq7dr7zwiw"; };
34 "4.08" = v6_6;
35 "4.09" = v6_6;
36 "4.10" = v6_6;
37 "4.11" = v6_6;
38 "4.12" = v6_6;
39 "4.13" = v6_6;
40 "4.14" = v6_6;
41 "5.0" = v6_6;
42 "5.1" = v6_6;
43}.${ocaml.meta.branch};
44in
45
46let src = fetchFromGitHub {
47 owner = "alainfrisch";
48 repo = pname;
49 rev = param.rev or param.version;
50 inherit (param) sha256;
51 };
52 pname = "ppx_tools";
53 meta = with lib; {
54 description = "Tools for authors of ppx rewriters";
55 homepage = "https://www.lexifi.com/ppx_tools";
56 license = licenses.mit;
57 maintainers = with maintainers; [ vbgl ];
58 };
59in
60if lib.versionAtLeast param.version "6.0"
61then
62 buildDunePackage {
63 inherit pname src meta;
64 inherit (param) version buildInputs nativeBuildInputs;
65 }
66else
67 stdenv.mkDerivation {
68 name = "ocaml${ocaml.version}-${pname}-${param.version}";
69
70 inherit src;
71
72 nativeBuildInputs = [ ocaml findlib ];
73
74 strictDeps = true;
75
76 createFindlibDestdir = true;
77
78 dontStrip = true;
79
80 meta = meta // { inherit (ocaml.meta) platforms; };
81 }