2021-02-26 17:35:41 +01:00
|
|
|
{ lib, stdenv, ocaml, findlib, dune_1, dune_2 }:
|
2018-11-05 11:21:46 +01:00
|
|
|
|
2021-08-07 14:00:00 +02:00
|
|
|
{ pname, version, nativeBuildInputs ? [], enableParallelBuilding ? true, ... }@args:
|
2018-11-05 11:21:46 +01:00
|
|
|
|
2022-03-13 15:39:14 +01:00
|
|
|
let Dune = if args.useDune2 or true then dune_2 else dune_1; in
|
2020-03-15 18:14:11 +01:00
|
|
|
|
2021-06-10 16:17:11 +02:00
|
|
|
if (args ? minimumOCamlVersion && ! lib.versionAtLeast ocaml.version args.minimumOCamlVersion) ||
|
|
|
|
(args ? minimalOCamlVersion && ! lib.versionAtLeast ocaml.version args.minimalOCamlVersion)
|
2018-11-05 11:21:46 +01:00
|
|
|
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
|
2020-04-28 11:20:00 +02:00
|
|
|
inherit enableParallelBuilding;
|
2021-08-14 14:00:00 +02:00
|
|
|
dontAddStaticConfigureFlags = true;
|
|
|
|
configurePlatforms = [];
|
2020-04-28 11:20:00 +02:00
|
|
|
|
2018-11-05 13:58:01 +01:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-04-28 11:20:00 +02:00
|
|
|
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2018-11-05 13:58:01 +01:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2020-04-28 11:20:00 +02:00
|
|
|
dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2018-11-05 13:58:01 +01:00
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2020-12-07 00:42:18 +01:00
|
|
|
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
|
2018-11-05 13:58:01 +01:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2018-11-05 11:21:46 +01:00
|
|
|
|
2021-06-10 16:17:11 +02:00
|
|
|
} // (builtins.removeAttrs args [ "minimalOCamlVersion" ]) // {
|
2018-11-05 11:21:46 +01:00
|
|
|
|
|
|
|
name = "ocaml${ocaml.version}-${pname}-${version}";
|
|
|
|
|
2021-08-07 14:00:00 +02:00
|
|
|
nativeBuildInputs = [ ocaml Dune findlib ] ++ nativeBuildInputs;
|
2018-11-05 11:21:46 +01:00
|
|
|
|
2018-11-27 16:30:55 +01:00
|
|
|
meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };
|
|
|
|
|
2018-11-05 11:21:46 +01:00
|
|
|
})
|