1{ lib
2, stdenv
3, fetchurl
4, pkg-config
5, intltool
6, itstool
7, libxml2
8, gtk3
9, openssl
10, gnome
11, gobject-introspection
12, vala
13, libgee
14, fetchpatch
15, autoreconfHook
16, gtk-doc
17, autoconf-archive
18, yelp-tools
19, mysqlSupport ? false
20, libmysqlclient
21, postgresSupport ? false
22, postgresql
23}:
24
25stdenv.mkDerivation rec {
26 pname = "libgda";
27 version = "5.2.10";
28
29 src = fetchurl {
30 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
31 sha256 = "1j1l4dwjgw6w4d1v4bl5a4kwyj7bcih8mj700ywm7xakh1xxyv3g";
32 };
33
34 patches = [
35 # fix compile error with mysql
36 (fetchpatch {
37 url = "https://gitlab.gnome.org/GNOME/libgda/-/commit/9859479884fad5f39e6c37e8995e57c28b11b1b9.diff";
38 sha256 = "158sncc5bg9lkri1wb0i1ri1nhx4c34rzi47gbfkwphlp7qd4qqv";
39 })
40 (fetchpatch {
41 name = "CVE-2021-39359.patch";
42 url = "https://src.fedoraproject.org/rpms/libgda5/raw/72bb769f12e861e27e883dac5fab34f1ba4bd97e/f/bebdffb4de586fb43fd07ac549121f4b22f6812d.patch";
43 sha256 = "sha256-hIKuY5NEqOzntdlLb541bA4xZU5ypTRmV1u765K6KbM=";
44 })
45 ];
46
47 nativeBuildInputs = [
48 pkg-config
49 intltool
50 itstool
51 gobject-introspection
52 vala
53 autoreconfHook
54 gtk-doc
55 autoconf-archive
56 yelp-tools
57 ];
58
59 buildInputs = [
60 gtk3
61 openssl
62 libgee
63 ] ++ lib.optionals mysqlSupport [
64 libmysqlclient
65 ] ++ lib.optionals postgresSupport [
66 postgresql
67 ];
68
69 propagatedBuildInputs = [
70 libxml2
71 ];
72
73 configureFlags = [
74 "--with-mysql=${if mysqlSupport then "yes" else "no"}"
75 "--with-postgres=${if postgresSupport then "yes" else "no"}"
76
77 # macOS builds use the sqlite source code that comes with libgda,
78 # as opposed to using the system or brewed sqlite3, which is not supported on macOS,
79 # as mentioned in https://github.com/GNOME/libgda/blob/95eeca4b0470f347c645a27f714c62aa6e59f820/libgda/sqlite/README#L31,
80 # which references the paper https://web.archive.org/web/20100610151539/http://lattice.umiacs.umd.edu/files/functions_tr.pdf
81 # See also https://github.com/Homebrew/homebrew-core/blob/104f9ecd02854a82372b64d63d41356555378a52/Formula/libgda.rb
82 "--enable-system-sqlite=${if stdenv.isDarwin then "no" else "yes"}"
83 ];
84
85 enableParallelBuilding = true;
86
87 hardeningDisable = [ "format" ];
88
89 passthru = {
90 updateScript = gnome.updateScript {
91 packageName = pname;
92 versionPolicy = "odd-unstable";
93 freeze = true;
94 };
95 };
96
97 meta = with lib; {
98 description = "Database access library";
99 homepage = "https://www.gnome-db.org/";
100 license = with licenses; [
101 # library
102 lgpl2Plus
103 # CLI tools
104 gpl2Plus
105 ];
106 maintainers = teams.gnome.members;
107 platforms = platforms.unix;
108 };
109}