diff --git a/pkgs/build-support/ocaml/oasis.nix b/pkgs/build-support/ocaml/oasis.nix new file mode 100644 index 00000000000..74977486f2f --- /dev/null +++ b/pkgs/build-support/ocaml/oasis.nix @@ -0,0 +1,46 @@ +{ stdenv, ocaml_oasis, ocaml, findlib, ocamlbuild }: + +{ pname, version, buildInputs ? [], meta ? { platforms = ocaml.meta.platforms or []; }, + minimumOCamlVersion ? null, + createFindlibDestdir ? true, + dontStrip ? true, + ... +}@args: + +if args ? minimumOCamlVersion && + ! stdenv.lib.versionAtLeast ocaml.version args.minimumOCamlVersion +then throw "${pname}-${version} is not available for OCaml ${ocaml.version}" +else + +stdenv.mkDerivation (args // { + name = "ocaml${ocaml.version}-${pname}-${version}"; + + buildInputs = [ ocaml findlib ocamlbuild ocaml_oasis ] ++ buildInputs; + + inherit createFindlibDestdir; + inherit dontStrip; + + buildPhase = '' + runHook preBuild + oasis setup + ocaml setup.ml -configure + ocaml setup.ml -build + runHook postBuild + ''; + + checkPhase = '' + runHook preCheck + ocaml setup.ml -test + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out + sed -i s+/usr/local+$out+g setup.ml + sed -i s+/usr/local+$out+g setup.data + prefix=$OCAMLFIND_DESTDIR ocaml setup.ml -install + runHook postInstall + ''; + +}) diff --git a/pkgs/development/ocaml-modules/tcslib/default.nix b/pkgs/development/ocaml-modules/tcslib/default.nix new file mode 100644 index 00000000000..9d1d5a8096c --- /dev/null +++ b/pkgs/development/ocaml-modules/tcslib/default.nix @@ -0,0 +1,25 @@ +{ lib, fetchFromGitHub, ocamlPackages, buildOasisPackage, ounit, ocaml_extlib, num }: + +buildOasisPackage rec { + pname = "tcslib"; + version = "0.3"; + + minimumOCamlVersion = "4.03.0"; + + src = fetchFromGitHub { + owner = "tcsprojects"; + repo = "tcslib"; + rev = "v${version}"; + sha256 = "05g6m82blsccq8wx8knxv6a5fzww7hi624jx91f9h87nk2fsplhi"; + }; + + buildInputs = [ ounit ]; + propagatedBuildInputs = [ ocaml_extlib num ]; + + meta = { + homepage = https://github.com/tcsprojects/tcslib; + description = "A multi-purpose library for OCaml"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ mgttlinger ]; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 1df001895b7..5249f848d01 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -12,6 +12,8 @@ let buildOcaml = callPackage ../build-support/ocaml { }; + buildOasisPackage = callPackage ../build-support/ocaml/oasis.nix { }; + buildDunePackage = callPackage ../build-support/ocaml/dune.nix {}; alcotest = callPackage ../development/ocaml-modules/alcotest {}; @@ -725,6 +727,8 @@ let stringext = callPackage ../development/ocaml-modules/stringext { }; + tcslib = callPackage ../development/ocaml-modules/tcslib { }; + toml = callPackage ../development/ocaml-modules/toml { }; topkg = callPackage ../development/ocaml-modules/topkg { };