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

67 lines
1.2 KiB
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{
lib,
stdenv,
ocaml_oasis,
ocaml,
findlib,
ocamlbuild,
}:
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
{
pname,
version,
nativeBuildInputs ? [ ],
meta ? {
platforms = ocaml.meta.platforms or [ ];
},
2024-05-02 00:46:19 +00:00
minimumOCamlVersion ? null,
createFindlibDestdir ? true,
dontStrip ? true,
...
}@args:
2024-06-30 08:16:52 +00:00
if args ? minimumOCamlVersion && lib.versionOlder ocaml.version args.minimumOCamlVersion then
throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
2024-05-02 00:46:19 +00:00
else
2024-06-30 08:16:52 +00:00
stdenv.mkDerivation (
args
// {
name = "ocaml${ocaml.version}-${pname}-${version}";
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
nativeBuildInputs = [
ocaml
findlib
ocamlbuild
ocaml_oasis
] ++ nativeBuildInputs;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
inherit createFindlibDestdir;
inherit dontStrip;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
strictDeps = true;
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
buildPhase = ''
runHook preBuild
oasis setup
ocaml setup.ml -configure --prefix $OCAMLFIND_DESTDIR --exec-prefix $out
ocaml setup.ml -build
runHook postBuild
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
checkPhase = ''
runHook preCheck
ocaml setup.ml -test
runHook postCheck
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
installPhase = ''
runHook preInstall
mkdir -p $out
ocaml setup.ml -install
runHook postInstall
'';
2024-05-02 00:46:19 +00:00
2024-06-30 08:16:52 +00:00
}
)