2021-03-09 03:18:52 +00:00
|
|
|
{ lib, stdenv, ocaml, findlib, dune_1, dune_2 }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
{ pname, version, buildInputs ? [], enableParallelBuilding ? true, ... }@args:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
let Dune = if args.useDune2 or false then dune_2 else dune_1; in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
if args ? minimumOCamlVersion &&
|
2021-02-05 17:12:51 +00:00
|
|
|
! lib.versionAtLeast ocaml.version args.minimumOCamlVersion
|
2020-04-24 23:36:52 +00:00
|
|
|
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
inherit enableParallelBuilding;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-05-03 17:38:23 +00:00
|
|
|
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2020-05-03 17:38:23 +00:00
|
|
|
dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2020-12-25 13:55:36 +00:00
|
|
|
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
} // args // {
|
|
|
|
|
|
|
|
name = "ocaml${ocaml.version}-${pname}-${version}";
|
|
|
|
|
|
|
|
buildInputs = [ ocaml Dune findlib ] ++ buildInputs;
|
|
|
|
|
|
|
|
meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };
|
|
|
|
|
|
|
|
})
|