1{
2 lib,
3 stdenv,
4 fetchurl,
5 ocaml,
6 findlib,
7 ocamlbuild,
8 topkg,
9 ctypes,
10 ctypes-foreign,
11 result,
12 SDL2,
13 pkg-config,
14}:
15
16if lib.versionOlder ocaml.version "4.03" then
17 throw "tsdl is not available for OCaml ${ocaml.version}"
18else
19
20 let
21 pname = "tsdl";
22 version = "1.1.0";
23 webpage = "https://erratique.ch/software/${pname}";
24 in
25
26 stdenv.mkDerivation {
27 pname = "ocaml${ocaml.version}-${pname}";
28 inherit version;
29
30 src = fetchurl {
31 url = "${webpage}/releases/${pname}-${version}.tbz";
32 hash = "sha256-ZN4+trqesU1IREKcwm1Ro37jszKG8XcVigoE4BdGhzs=";
33 };
34
35 strictDeps = true;
36
37 nativeBuildInputs = [
38 pkg-config
39 ocaml
40 findlib
41 ocamlbuild
42 topkg
43 ];
44 buildInputs = [ topkg ];
45 propagatedBuildInputs = [
46 SDL2
47 ctypes
48 ctypes-foreign
49 ];
50
51 preConfigure = ''
52 # The following is done to avoid an additional dependency (ncurses)
53 # due to linking in the custom bytecode runtime. Instead, just
54 # compile directly into a native binary, even if it's just a
55 # temporary build product.
56 substituteInPlace myocamlbuild.ml \
57 --replace ".byte" ".native"
58 '';
59
60 inherit (topkg) buildPhase installPhase;
61
62 meta = with lib; {
63 homepage = webpage;
64 description = "Thin bindings to the cross-platform SDL library";
65 license = licenses.isc;
66 inherit (ocaml.meta) platforms;
67 };
68 }