summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/ppx_deriving/default.nix
blob: 24cfbcf5b7af0509ce531296be7856222a1a12a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ stdenv, ocaml, findlib, ocamlbuild, fetchzip
, cppo, ppx_tools, ppx_derivers, result, ounit, ocaml-migrate-parsetree
}:

if !stdenv.lib.versionAtLeast ocaml.version "4.02"
then throw "ppx_deriving is not available for OCaml ${ocaml.version}"
else

let param =
  if ocaml.version == "4.03.0"
  then {
    version = "4.1";
    sha256 = "0cy9p8d8cbcxvqyyv8fz2z9ypi121zrgaamdlp4ld9f3jnwz7my9";
    extraPropagatedBuildInputs = [];
  } else {
    version = "4.2.1";
    sha256 = "1yhhjnncbbb7fsif7qplndh01s1xd72dqm8f3jkgx9y4ariqqvf9";
    extraPropagatedBuildInputs = [ ocaml-migrate-parsetree ppx_derivers ];
}; in

stdenv.mkDerivation rec {
  name = "ocaml${ocaml.version}-ppx_deriving-${version}";
  inherit (param) version;

  src = fetchzip {
    url = "https://github.com/ocaml-ppx/ppx_deriving/archive/v${version}.tar.gz";
    inherit (param) sha256;
  };

  buildInputs = [ ocaml findlib ocamlbuild cppo ounit ];
  propagatedBuildInputs = param.extraPropagatedBuildInputs ++
    [ ppx_tools result ];

  createFindlibDestdir = true;

  installPhase = "OCAMLPATH=$OCAMLPATH:`ocamlfind printconf destdir` make install";

  meta = with stdenv.lib; {
    description = "deriving is a library simplifying type-driven code generation on OCaml >=4.02.";
    maintainers = [ maintainers.maurer ];
    license = licenses.mit;
  };
}