forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / ocaml-modules / tsdl / default.nix
blob0e4b1cf83e2c21458091a83a26889872954d2c02
1 { lib, stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ctypes, ctypes-foreign, result, SDL2, pkg-config
2 , AudioToolbox, Cocoa, CoreAudio, CoreVideo, ForceFeedback }:
4 if lib.versionOlder ocaml.version "4.03"
5 then throw "tsdl is not available for OCaml ${ocaml.version}"
6 else
8 let
9   pname = "tsdl";
10   version = "1.1.0";
11   webpage = "https://erratique.ch/software/${pname}";
14 stdenv.mkDerivation {
15   pname = "ocaml${ocaml.version}-${pname}";
16   inherit version;
18   src = fetchurl {
19     url = "${webpage}/releases/${pname}-${version}.tbz";
20     hash = "sha256-ZN4+trqesU1IREKcwm1Ro37jszKG8XcVigoE4BdGhzs=";
21   };
23   strictDeps = true;
25   nativeBuildInputs = [ pkg-config ocaml findlib ocamlbuild topkg ];
26   buildInputs = [ topkg ];
27   propagatedBuildInputs = [ SDL2 ctypes ctypes-foreign ]
28     ++ lib.optionals stdenv.hostPlatform.isDarwin [ AudioToolbox Cocoa CoreAudio CoreVideo ForceFeedback ];
30   preConfigure = ''
31     # The following is done to avoid an additional dependency (ncurses)
32     # due to linking in the custom bytecode runtime. Instead, just
33     # compile directly into a native binary, even if it's just a
34     # temporary build product.
35     substituteInPlace myocamlbuild.ml \
36       --replace ".byte" ".native"
37   '';
39   inherit (topkg) buildPhase installPhase;
41   meta = with lib; {
42     homepage = webpage;
43     description = "Thin bindings to the cross-platform SDL library";
44     license = licenses.isc;
45     inherit (ocaml.meta) platforms;
46   };