2020-03-15 17:14:11 +00:00
|
|
|
{ stdenv, ocaml, findlib, dune, dune_2, opaline }:
|
2018-11-05 10:21:46 +00:00
|
|
|
|
|
|
|
{ pname, version, buildInputs ? [], ... }@args:
|
|
|
|
|
2020-03-15 17:14:11 +00:00
|
|
|
let Dune = if args.useDune2 or false then dune_2 else dune; in
|
|
|
|
|
2018-11-05 10:21:46 +00:00
|
|
|
if args ? minimumOCamlVersion &&
|
|
|
|
! stdenv.lib.versionAtLeast ocaml.version args.minimumOCamlVersion
|
|
|
|
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
|
2018-11-05 12:58:01 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
dune build -p ${pname}
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
dune runtest -p ${pname}
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2018-11-06 16:18:09 +00:00
|
|
|
${opaline}/bin/opaline -prefix $out -libdir $OCAMLFIND_DESTDIR
|
2018-11-05 12:58:01 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2018-11-05 10:21:46 +00:00
|
|
|
|
|
|
|
} // args // {
|
|
|
|
|
|
|
|
name = "ocaml${ocaml.version}-${pname}-${version}";
|
|
|
|
|
2020-03-15 17:14:11 +00:00
|
|
|
buildInputs = [ ocaml Dune findlib ] ++ buildInputs;
|
2018-11-05 10:21:46 +00:00
|
|
|
|
2018-11-27 15:30:55 +00:00
|
|
|
meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };
|
|
|
|
|
2018-11-05 10:21:46 +00:00
|
|
|
})
|