@@ -1,28 +1,29 @@
1−{ stdenv, buildOcaml, fetchzip, libffi, pkgconfig, ncurses, integers }:
1+{ stdenv, fetchzip, ocaml, findlib, libffi, pkgconfig, ncurses, integers }:
22
3−buildOcaml {
4− name = "ctypes";
5− version = "0.13.1";
3+if !stdenv.lib.versionAtLeast ocaml.version "4.02"
4+then throw "ctypes is not available for OCaml ${ocaml.version}"
5+else
66
7− minimumSupportedOcamlVersion = "4";
7+stdenv.mkDerivation rec {
8+ name = "ocaml${ocaml.version}-ctypes-${version}";
9+ version = "0.15.1";
810
911 src = fetchzip {
10− url = "https://github.com/ocamllabs/ocaml-ctypes/archive/67e711ec891e087fbe1e0b4665aa525af4eaa409.tar.gz";
11− sha256 = "1z84s5znr3lj84rzv6m37xxj9h7fwx4qiiykx3djf52qgk1rb2xb";
12+ url = "https://github.com/ocamllabs/ocaml-ctypes/archive/${version}.tar.gz";
13+ sha256 = "0adas974bwinn8jidb6chljkpd70s041h2a969dicsj0xsg6wys6";
1214 };
1315
1416 nativeBuildInputs = [ pkgconfig ];
15− buildInputs = [ ncurses ];
17+ buildInputs = [ ocaml findlib ncurses ];
1618 propagatedBuildInputs = [ integers libffi ];
1719
18− hasSharedObjects = true;
19−
2020 buildPhase = ''
2121 make XEN=false libffi.config ctypes-base ctypes-stubs
2222 make XEN=false ctypes-foreign
2323 '';
2424
2525 installPhase = ''
26+ mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs
2627 make install XEN=false
2728 '';
2829
@@ -31,5 +32,6 @@ buildOcaml {
3132 description = "Library for binding to C libraries using pure OCaml";
3233 license = licenses.mit;
3334 maintainers = [ maintainers.ericbmerritt ];
35+ inherit (ocaml.meta) platforms;
3436 };
3537}