summaryrefslogtreecommitdiffstats
path: root/pkgs/development/ocaml-modules/ppx_deriving_yojson/default.nix
blob: 8849f608d2013196ddc2055073ec70b2ac8bd0fd (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  lib,
  buildDunePackage,
  fetchFromGitHub,
  fetchpatch,
  ocaml,
  ppxlib,
  ounit,
  ounit2,
  ppx_deriving,
  result,
  yojson,
}:

let
  param =
    if lib.versionAtLeast ppxlib.version "0.36" then
      {
        version = "3.10.0";
        sha256 = "sha256-Dy9egNpZdxsTPLo2mbpiFTMh5cYUXXOlOZLlQJuAK+E=";
        checkInputs = [ ounit2 ];
      }
    else if lib.versionAtLeast ppxlib.version "0.30" then
      {
        version = "3.9.0";
        sha256 = "sha256-0d6YcBkeFoHXffCYjLIIvruw8B9ZB6NbUijhTv9uyN8=";
        checkInputs = [ ounit2 ];
      }
    else
      {
        version = "3.6.1";
        sha256 = "1icz5h6p3pfj7my5gi7wxpflrb8c902dqa17f9w424njilnpyrbk";
        checkInputs = [ ounit ];
        propagatedBuildInputs = [ result ];
      };
in

buildDunePackage (finalAttrs: {
  pname = "ppx_deriving_yojson";
  inherit (param) version;

  patches = fetchpatch {
    url = "https://github.com/ocaml-ppx/ppx_deriving_yojson/commit/1bbbe2c4c5822c4297b0b812c59a155cf96c5089.patch";
    hash = "sha256-jYW2/Ix6T94vfI2mGnIkYSG1rjsWEsnOPA1mufP3sd4=";
  };

  src = fetchFromGitHub {
    owner = "ocaml-ppx";
    repo = "ppx_deriving_yojson";
    rev = "v${finalAttrs.version}";
    inherit (param) sha256;
  };

  propagatedBuildInputs = [
    ppxlib
    ppx_deriving
    yojson
  ]
  ++ param.propagatedBuildInputs or [ ];

  doCheck = true;
  inherit (param) checkInputs;

  meta = {
    description = "Yojson codec generator for OCaml >= 4.04";
    inherit (finalAttrs.src.meta) homepage;
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.vbgl ];
  };
})