nixpkgs/pkgs/build-support/ocaml/oasis.nix

45 lines
1.0 KiB
Nix
Raw Normal View History

2021-01-24 00:40:18 +00:00
{ lib, stdenv, ocaml_oasis, ocaml, findlib, ocamlbuild }:
2019-08-07 08:50:46 +01:00
{ pname, version, buildInputs ? [], meta ? { platforms = ocaml.meta.platforms or []; },
minimumOCamlVersion ? null,
2019-08-06 16:54:09 +01:00
createFindlibDestdir ? true,
dontStrip ? true,
...
}@args:
2019-08-07 08:50:46 +01:00
if args ? minimumOCamlVersion &&
2021-01-24 00:40:18 +00:00
! lib.versionAtLeast ocaml.version args.minimumOCamlVersion
2019-08-07 08:50:46 +01:00
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
else
2019-08-06 16:54:09 +01:00
stdenv.mkDerivation (args // {
2019-08-07 08:50:46 +01:00
name = "ocaml${ocaml.version}-${pname}-${version}";
2019-08-06 16:54:09 +01:00
2019-08-07 05:51:36 +01:00
buildInputs = [ ocaml findlib ocamlbuild ocaml_oasis ] ++ buildInputs;
2019-08-06 16:54:09 +01:00
inherit createFindlibDestdir;
inherit dontStrip;
buildPhase = ''
runHook preBuild
oasis setup
ocaml setup.ml -configure --prefix $OCAMLFIND_DESTDIR --exec-prefix $out
ocaml setup.ml -build
runHook postBuild
'';
checkPhase = ''
runHook preCheck
ocaml setup.ml -test
runHook postCheck
'';
installPhase = ''
runHook preInstall
mkdir -p $out
ocaml setup.ml -install
runHook postInstall
'';
2019-08-06 16:54:09 +01:00
})