summaryrefslogtreecommitdiff
path: root/pkgs/development/tools/ocaml/cppo/default.nix
blob: b46c1122a4b363d78df52cb4c66e4338de9d4739 (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
71
72
73
74
75
76
77
78
79
{
  lib,
  stdenv,
  fetchFromGitHub,
  ocaml,
  findlib,
  ocamlbuild,
  buildDunePackage,
}:

let
  pname = "cppo";

  meta = {
    description = "C preprocessor for OCaml";
    mainProgram = "cppo";
    longDescription = ''
      Cppo is an equivalent of the C preprocessor targeted at the OCaml language and its variants.
    '';
    homepage = "https://github.com/ocaml-community/${pname}";
    maintainers = [ lib.maintainers.vbgl ];
    license = lib.licenses.bsd3;
  };

in

if lib.versionAtLeast ocaml.version "4.02" then

  buildDunePackage rec {
    inherit pname;
    version = "1.8.0";

    src = fetchFromGitHub {
      owner = "ocaml-community";
      repo = pname;
      rev = "v${version}";
      hash = "sha256-+HnAGM+GddYJK0RCvKrs+baZS+1o8Yq+/cVa3U3nFWg=";
    };

    doCheck = true;

    inherit meta;
  }

else

  let
    version = "1.5.0";
  in

  stdenv.mkDerivation {
    inherit pname version;

    src = fetchFromGitHub {
      owner = "mjambon";
      repo = pname;
      rev = "v${version}";
      sha256 = "1xqldjz9risndnabvadw41fdbi5sa2hl4fnqls7j9xfbby1izbg8";
    };

    strictDeps = true;

    nativeBuildInputs = [
      ocaml
      findlib
      ocamlbuild
    ];

    inherit meta;

    createFindlibDestdir = true;

    makeFlags = [ "PREFIX=$(out)" ];

    preBuild = ''
      mkdir -p $out/bin
    '';

  }