2021-02-26 16:35:41 +00:00
|
|
|
{ lib, stdenv, ocaml, findlib, dune_1, dune_2 }:
|
2018-11-05 10:21:46 +00:00
|
|
|
|
2020-04-28 09:20:00 +00:00
|
|
|
{ pname, version, buildInputs ? [], enableParallelBuilding ? true, ... }@args:
|
2018-11-05 10:21:46 +00:00
|
|
|
|
2021-02-26 16:35:41 +00:00
|
|
|
let Dune = if args.useDune2 or false then dune_2 else dune_1; in
|
2020-03-15 17:14:11 +00:00
|
|
|
|
2018-11-05 10:21:46 +00:00
|
|
|
if args ? minimumOCamlVersion &&
|
2021-01-24 00:40:18 +00:00
|
|
|
! lib.versionAtLeast ocaml.version args.minimumOCamlVersion
|
2018-11-05 10:21:46 +00:00
|
|
|
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
|
2020-04-28 09:20:00 +00:00
|
|
|
inherit enableParallelBuilding;
|
|
|
|
|
2018-11-05 12:58:01 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-04-28 09:20:00 +00:00
|
|
|
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2018-11-05 12:58:01 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2020-04-28 09:20:00 +00:00
|
|
|
dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2018-11-05 12:58:01 +00:00
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2020-12-06 23:42:18 +00:00
|
|
|
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
|
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
|
|
|
})
|