1{
2 lib,
3 fetchurl,
4 stdenv,
5 fetchpatch,
6 ocaml,
7 findlib,
8 ocamlbuild,
9 camlp-streams,
10 ctypes,
11 mariadb,
12 libmysqlclient,
13}:
14
15lib.throwIfNot (lib.versionAtLeast ocaml.version "4.07")
16 "mariadb is not available for OCaml ${ocaml.version}"
17
18 stdenv.mkDerivation
19 rec {
20 pname = "ocaml${ocaml.version}-mariadb";
21 version = "1.1.6";
22
23 src = fetchurl {
24 url = "https://github.com/andrenth/ocaml-mariadb/releases/download/${version}/ocaml-mariadb-${version}.tar.gz";
25 sha256 = "sha256-3/C1Gz6luUzS7oaudLlDHMT6JB2v5OdbLVzJhtayHGM=";
26 };
27
28 patches =
29 lib.lists.map
30 (
31 x:
32 fetchpatch {
33 url = "https://github.com/andrenth/ocaml-mariadb/commit/${x.path}.patch";
34 inherit (x) hash;
35 }
36 )
37 [
38 {
39 path = "9db2e4d8dec7c584213d0e0f03d079a36a35d9d5";
40 hash = "sha256-heROtU02cYBJ5edIHMdYP1xNXcLv8h79GYGBuudJhgE=";
41 }
42 {
43 path = "40cd3102bc7cce4ed826ed609464daeb1bbb4581";
44 hash = "sha256-YVsAMJiOgWRk9xPaRz2sDihBYLlXv+rhWtQIMOVLtSg=";
45 }
46 ];
47
48 postPatch = ''
49 substituteInPlace setup.ml --replace '#use "topfind"' \
50 '#directory "${findlib}/lib/ocaml/${ocaml.version}/site-lib/";; #use "topfind"'
51 '';
52
53 nativeBuildInputs = [
54 ocaml
55 findlib
56 ocamlbuild
57 ];
58 buildInputs = [
59 mariadb
60 libmysqlclient
61 camlp-streams
62 ocamlbuild
63 ];
64 propagatedBuildInputs = [ ctypes ];
65
66 strictDeps = true;
67
68 preInstall = "mkdir -p $OCAMLFIND_DESTDIR/stublibs";
69
70 meta = {
71 description = "OCaml bindings for MariaDB";
72 license = lib.licenses.mit;
73 maintainers = with lib.maintainers; [ bcc32 ];
74 homepage = "https://github.com/andrenth/ocaml-mariadb";
75 inherit (ocaml.meta) platforms;
76 };
77 }