summary refs log tree commit diff
path: root/pkgs/development/tools/ocaml/cppo/default.nix
blob: 8aa446081b72b48942e9ce88108778c5f0d3b1b0 (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
44
45
46
47
48
49
50
51
{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, dune }:
let
  pname = "cppo";
  webpage = "https://github.com/ocaml-community/${pname}";
in
assert stdenv.lib.versionAtLeast ocaml.version "3.12";

let param =
  if stdenv.lib.versionAtLeast ocaml.version "4.02" then {
    version = "1.6.6";
    sha256 = "1smcc0l6fh2n0y6bp96c69j5nw755jja99w0b206wx3yb2m4w2hs";
    buildInputs = [ dune ];
    extra = {
      inherit (dune) installPhase;
    };
  } else {
    version = "1.5.0";
    sha256 = "1xqldjz9risndnabvadw41fdbi5sa2hl4fnqls7j9xfbby1izbg8";
    extra = {
      createFindlibDestdir = true;
      makeFlags = "PREFIX=$(out)";
      preBuild = ''
        mkdir $out/bin
      '';
    };
  }
; in

stdenv.mkDerivation ({

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

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

  buildInputs = [ ocaml findlib ocamlbuild ] ++ (param.buildInputs or []);

  meta = with stdenv.lib; {
    description = "The C preprocessor for OCaml";
    longDescription = ''
      Cppo is an equivalent of the C preprocessor targeted at the OCaml language and its variants.
    '';
    homepage = webpage;
    maintainers = [ maintainers.vbgl ];
    license = licenses.bsd3;
  };
} // param.extra)