about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/ocaml/default.nix
blob: cd17eb688c2e4dca0290fe068b7c44fe0b2437fc (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
{ lib, stdenv, writeText, ocaml, findlib, ocamlbuild, camlp4 }:

{ name, version, nativeBuildInputs ? [],
  createFindlibDestdir ?  true,
  dontStrip ? true,
  minimumSupportedOcamlVersion ? null,
  hasSharedObjects ? false,
  setupHook ? null,
  meta ? {}, ...
}@args:
let
  defaultMeta = {
    platforms = ocaml.meta.platforms or [];
  };
in
  assert minimumSupportedOcamlVersion != null ->
          lib.versionOlder minimumSupportedOcamlVersion ocaml.version;

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

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

  setupHook = if setupHook == null && hasSharedObjects
  then writeText "setupHook.sh" ''
    export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/${name}/"
    ''
  else setupHook;

  inherit createFindlibDestdir;
  inherit dontStrip;

  meta = defaultMeta // meta;
})