You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
3 years ago
|
{ lib, stdenv, ocaml, findlib, dune_1, dune_2 }:
|
||
6 years ago
|
|
||
4 years ago
|
{ pname, version, buildInputs ? [], enableParallelBuilding ? true, ... }@args:
|
||
6 years ago
|
|
||
3 years ago
|
let Dune = if args.useDune2 or false then dune_2 else dune_1; in
|
||
4 years ago
|
|
||
3 years ago
|
if (args ? minimumOCamlVersion && ! lib.versionAtLeast ocaml.version args.minimumOCamlVersion) ||
|
||
|
(args ? minimalOCamlVersion && ! lib.versionAtLeast ocaml.version args.minimalOCamlVersion)
|
||
6 years ago
|
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
||
|
else
|
||
|
|
||
|
stdenv.mkDerivation ({
|
||
|
|
||
4 years ago
|
inherit enableParallelBuilding;
|
||
|
|
||
6 years ago
|
buildPhase = ''
|
||
|
runHook preBuild
|
||
4 years ago
|
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
||
6 years ago
|
runHook postBuild
|
||
|
'';
|
||
|
checkPhase = ''
|
||
|
runHook preCheck
|
||
4 years ago
|
dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
||
6 years ago
|
runHook postCheck
|
||
|
'';
|
||
|
installPhase = ''
|
||
|
runHook preInstall
|
||
4 years ago
|
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
|
||
6 years ago
|
runHook postInstall
|
||
|
'';
|
||
6 years ago
|
|
||
3 years ago
|
} // (builtins.removeAttrs args [ "minimalOCamlVersion" ]) // {
|
||
6 years ago
|
|
||
|
name = "ocaml${ocaml.version}-${pname}-${version}";
|
||
|
|
||
4 years ago
|
buildInputs = [ ocaml Dune findlib ] ++ buildInputs;
|
||
6 years ago
|
|
||
6 years ago
|
meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };
|
||
|
|
||
6 years ago
|
})
|