1{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ctypes, result, SDL2, pkgconfig, opam, ocb-stubblr }:
2
3if !stdenv.lib.versionAtLeast ocaml.version "4.02"
4then throw "tsdl is not available for OCaml ${ocaml.version}"
5else
6
7let
8 pname = "tsdl";
9 version = "0.9.4";
10 webpage = "http://erratique.ch/software/${pname}";
11in
12
13stdenv.mkDerivation {
14 name = "ocaml${ocaml.version}-${pname}-${version}";
15
16 src = fetchurl {
17 url = "${webpage}/releases/${pname}-${version}.tbz";
18 sha256 = "13af37w2wybx8yzgjr5zz5l50402ldl614qiwphl1q69hig5mag2";
19 };
20
21 buildInputs = [ ocaml findlib ocamlbuild topkg result pkgconfig opam ocb-stubblr ];
22 propagatedBuildInputs = [ SDL2 ctypes ];
23
24 createFindlibDestdir = true;
25
26 unpackCmd = "tar xjf $src";
27
28 preConfigure = ''
29 # The following is done to avoid an additional dependency (ncurses)
30 # due to linking in the custom bytecode runtime. Instead, just
31 # compile directly into a native binary, even if it's just a
32 # temporary build product.
33 substituteInPlace myocamlbuild.ml \
34 --replace ".byte" ".native"
35 '';
36
37 inherit (topkg) buildPhase installPhase;
38
39 meta = with stdenv.lib; {
40 homepage = "${webpage}";
41 description = "Thin bindings to the cross-platform SDL library";
42 license = licenses.bsd3;
43 platforms = ocaml.meta.platforms or [];
44 };
45}