about summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/yojson/default.nix
blob: f494a8cf17ccd014e700c490ea2bd8d9c6fb5cf6 (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, fetchzip, ocaml, findlib, jbuilder, cppo, easy-format, biniou }:
let
  pname = "yojson";
  param =
  if stdenv.lib.versionAtLeast ocaml.version "4.02" then {
    version = "1.4.1";
    sha256 = "0nwsfkmqpyfab4rxq76q8ff7giyanghw08094jyrp275v99zdjr9";
    buildInputs = [ jbuilder ];
    extra = { inherit (jbuilder) installPhase; };
  } else {
    version = "1.2.3";
    sha256 = "10dvkndgwanvw4agbjln7kgb1n9s6lii7jw82kwxczl5rd1sgmvl";
    buildInputs = [];
    extra = {
      createFindlibDestdir = true;

      makeFlags = "PREFIX=$(out)";

      preBuild = "mkdir $out/bin";
    };
  };
in
stdenv.mkDerivation ({

  name = "ocaml${ocaml.version}-${pname}-${param.version}";

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

  buildInputs = [ ocaml findlib ] ++ param.buildInputs;

  propagatedBuildInputs = [ cppo easy-format biniou ];

  meta = with stdenv.lib; {
    description = "An optimized parsing and printing library for the JSON format";
    homepage = "http://mjambon.com/${pname}.html";
    license = licenses.bsd3;
    maintainers = [ maintainers.vbgl ];
    platforms = ocaml.meta.platforms or [];
  };
} // param.extra)