1{ lib, stdenv, fetchurl, libdbi
2# TODO: migrate away from overriding packages to null
3, libmysqlclient ? null
4, sqlite ? null
5, postgresql ? null
6}:
7
8stdenv.mkDerivation rec {
9 pname = "libdbi-drivers";
10 version = "0.9.0";
11
12 src = fetchurl {
13 url = "mirror://sourceforge/libdbi-drivers/libdbi-drivers-${version}.tar.gz";
14 sha256 = "0m680h8cc4428xin4p733azysamzgzcmv4psjvraykrsaz6ymlj3";
15 };
16
17 buildInputs = [ libdbi sqlite postgresql ] ++ lib.optional (libmysqlclient != null) libmysqlclient;
18
19 patches = [
20 # https://sourceforge.net/p/libdbi-drivers/libdbi-drivers/ci/24f48b86c8988ee3aaebc5f303d71e9d789f77b6
21 ./libdbi-drivers-0.9.0-buffer_overflow.patch
22 ];
23
24 postPatch = ''
25 sed -i '/SQLITE3_LIBS/ s/-lsqlite/-lsqlite3/' configure;
26 '';
27
28 configureFlags = [
29 "--sysconfdir=/etc"
30 "--localstatedir=/var"
31 "--disable-docs"
32 "--enable-libdbi"
33 "--with-dbi-incdir=${libdbi}/include"
34 "--with-dbi-libdir=${libdbi}/lib"
35 ] ++ lib.optionals (libmysqlclient != null) [
36 "--with-mysql"
37 "--with-mysql-incdir=${lib.getDev libmysqlclient}/include/mysql"
38 "--with-mysql-libdir=${libmysqlclient}/lib/mysql"
39 ] ++ lib.optionals (sqlite != null) [
40 "--with-sqlite3"
41 "--with-sqlite3-incdir=${sqlite.dev}/include/sqlite"
42 "--with-sqlite3-libdir=${sqlite.out}/lib/sqlite"
43 ] ++ lib.optionals (postgresql != null) [
44 "--with-pgsql"
45 "--with-pgsql_incdir=${postgresql}/include"
46 "--with-pgsql_libdir=${postgresql.lib}/lib"
47 ];
48
49 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [
50 "-Wno-error=incompatible-function-pointer-types"
51 "-Wno-error=int-conversion"
52 ]);
53
54 installFlags = [ "DESTDIR=\${out}" ];
55
56 postInstall = ''
57 mv $out/$out/* $out
58 DIR=$out/$out
59 while rmdir $DIR 2>/dev/null; do
60 DIR="$(dirname "$DIR")"
61 done
62
63 # Remove the unneeded var/lib directories
64 rm -rf $out/var
65 '';
66
67 meta = with lib; {
68 homepage = "https://libdbi-drivers.sourceforge.net/";
69 description = "Database drivers for libdbi";
70 platforms = platforms.all;
71 license = licenses.lgpl21;
72 maintainers = with maintainers; [ ];
73 };
74}