summaryrefslogtreecommitdiffstats
path: root/pkgs/build-support/ocaml/oasis.nix
blob: de8b7039e84e384a01a002f27987fdfaab24aade (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
{
  lib,
  stdenv,
  ocaml_oasis,
  ocaml,
  findlib,
  ocamlbuild,
}:

{
  pname,
  version,
  nativeBuildInputs ? [ ],
  meta ? {
    platforms = ocaml.meta.platforms or [ ];
  },
  minimumOCamlVersion ? null,
  createFindlibDestdir ? true,
  dontStrip ? true,
  ...
}@args:

stdenv.mkDerivation (
  args
  // {
    name = "ocaml${ocaml.version}-${pname}-${version}";

    nativeBuildInputs = [
      ocaml
      findlib
      ocamlbuild
      ocaml_oasis
    ]
    ++ nativeBuildInputs;

    inherit createFindlibDestdir;
    inherit dontStrip;

    strictDeps = true;

    buildPhase = ''
      runHook preBuild
      oasis setup
      ocaml setup.ml -configure --prefix $OCAMLFIND_DESTDIR --exec-prefix $out
      ocaml setup.ml -build
      runHook postBuild
    '';

    checkPhase = ''
      runHook preCheck
      ocaml setup.ml -test
      runHook postCheck
    '';

    installPhase = ''
      runHook preInstall
      mkdir -p $out
      ocaml setup.ml -install
      runHook postInstall
    '';

    meta = args.meta // {
      broken = args ? minimumOCamlVersion && lib.versionOlder ocaml.version args.minimumOCamlVersion;
    };
  }
)