nixpkgs/pkgs/build-support/ocaml/default.nix

35 lines
971 B
Nix
Raw Normal View History

2021-01-24 01:40:18 +01:00
{ lib, stdenv, writeText, ocaml, findlib, ocamlbuild, camlp4 }:
2021-10-31 13:35:20 +01:00
{ pname ? args.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 ->
2021-01-24 01:40:18 +01:00
lib.versionOlder minimumSupportedOcamlVersion ocaml.version;
stdenv.mkDerivation (args // {
2021-10-31 13:35:20 +01:00
name = "ocaml-${pname}-${version}";
nativeBuildInputs = [ ocaml findlib ocamlbuild camlp4 ] ++ nativeBuildInputs;
setupHook = if setupHook == null && hasSharedObjects
then writeText "setupHook.sh" ''
2021-10-31 13:35:20 +01:00
export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/${pname}/"
''
else setupHook;
inherit createFindlibDestdir;
inherit dontStrip;
meta = defaultMeta // meta;
})