1 { fetchurl, stdenv, unixODBC, cmake, postgresql, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, libkrb5, libuuid, patchelf, libiconv, fetchFromGitHub }:
3 # I haven't done any parameter tweaking.. So the defaults provided here might be bad
6 psql = stdenv.mkDerivation rec {
8 version = "10.01.0000";
11 url = "mirror://postgresql/odbc/versions/src/${pname}-${version}.tar.gz";
12 sha256 = "1cyams7157f3gry86x64xrplqi2vyqrq3rqka59gv4lb4rpl7jl7";
15 buildInputs = [ unixODBC postgresql ];
18 fancyName = "PostgreSQL";
19 driver = "lib/psqlodbcw.so";
23 broken = stdenv.isDarwin;
24 description = "Official PostgreSQL ODBC Driver";
25 homepage = "https://odbc.postgresql.org/";
26 license = licenses.lgpl2;
27 platforms = platforms.linux;
31 mariadb = stdenv.mkDerivation rec {
32 pname = "mariadb-connector-odbc";
35 src = fetchFromGitHub {
36 owner = "mariadb-corporation";
37 repo = "mariadb-connector-odbc";
39 sha256 = "0wvy6m9qfvjii3kanf2d1rhfaww32kg0d7m57643f79qb05gd6vg";
40 # this driver only seems to build correctly when built against the mariadb-connect-c subrepo
41 # (see https://github.com/NixOS/nixpkgs/issues/73258)
42 fetchSubmodules = true;
45 nativeBuildInputs = [ cmake ];
46 buildInputs = [ unixODBC openssl libiconv ];
49 # we don't want to build a .pkg
50 sed -i 's/ADD_SUBDIRECTORY(osxinstall)//g' CMakeLists.txt
55 # on darwin this defaults to ON but we want to build against unixODBC
60 fancyName = "MariaDB";
61 driver = "lib/libmaodbc${stdenv.hostPlatform.extensions.sharedLibrary}";
65 broken = stdenv.isDarwin;
66 description = "MariaDB ODBC database driver";
67 homepage = "https://downloads.mariadb.org/connector-odbc/";
68 license = licenses.gpl2;
69 platforms = platforms.linux ++ platforms.darwin;
73 mysql = stdenv.mkDerivation rec {
74 pname = "mysql-connector-odbc";
76 version = "${majorVersion}.6";
79 url = "https://dev.mysql.com/get/Downloads/Connector-ODBC/${majorVersion}/${pname}-${version}-src.tar.gz";
80 sha256 = "1smi4z49i4zm7cmykjkwlxxzqvn7myngsw5bc35z6gqxmi8c55xr";
83 nativeBuildInputs = [ cmake ];
84 buildInputs = [ unixODBC mariadb ];
86 cmakeFlags = [ "-DWITH_UNIXODBC=1" ];
90 driver = "lib/libmyodbc3-3.51.12.so";
94 description = "MySQL ODBC database driver";
95 homepage = "https://dev.mysql.com/downloads/connector/odbc/";
96 license = licenses.gpl2;
97 platforms = platforms.linux;
102 sqlite = stdenv.mkDerivation rec {
103 pname = "sqlite-connector-odbc";
107 url = "http://www.ch-werner.de/sqliteodbc/sqliteodbc-${version}.tar.gz";
108 sha256 = "0dgsj28sc7f7aprmdd0n5a1rmcx6pv7170c8dfjl0x1qsjxim6hs";
111 buildInputs = [ unixODBC sqlite zlib libxml2 ];
113 configureFlags = [ "--with-odbc=${unixODBC}" "--with-sqlite3=${sqlite.dev}" ];
115 installTargets = [ "install-3" ];
117 # move libraries to $out/lib where they're expected to be
120 mv "$out"/*.* "$out/lib"
124 fancyName = "SQLite";
125 driver = "lib/libsqlite3odbc.so";
129 broken = stdenv.isDarwin;
130 description = "ODBC driver for SQLite";
131 homepage = "http://www.ch-werner.de/sqliteodbc";
132 license = licenses.bsd2;
133 platforms = platforms.linux;
134 maintainers = with maintainers; [ vlstill ];
138 msodbcsql17 = stdenv.mkDerivation rec {
139 pname = "msodbcsql17";
140 version = "${versionMajor}.${versionMinor}.${versionAdditional}-1";
144 versionAdditional = "1.1";
147 url = "https://packages.microsoft.com/debian/10/prod/pool/main/m/msodbcsql17/msodbcsql${versionMajor}_${version}_amd64.deb";
148 sha256 = "0vwirnp56jibm3qf0kmi4jnz1w7xfhnsfr8imr0c9hg6av4sk3a6";
151 nativeBuildInputs = [ dpkg patchelf ];
153 unpackPhase = "dpkg -x $src ./";
159 cp -r opt/microsoft/msodbcsql${versionMajor}/lib64 opt/microsoft/msodbcsql${versionMajor}/share $out/
163 patchelf --set-rpath ${lib.makeLibraryPath [ unixODBC openssl libkrb5 libuuid stdenv.cc.cc ]} \
164 $out/lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}
168 fancyName = "ODBC Driver 17 for SQL Server";
169 driver = "lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}";
173 broken = stdenv.isDarwin;
174 description = "ODBC Driver 17 for SQL Server";
175 homepage = "https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017";
176 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
177 license = licenses.unfree;
178 platforms = platforms.linux;
179 maintainers = with maintainers; [ spencerjanssen ];
183 redshift = stdenv.mkDerivation rec {
184 pname = "redshift-odbc";
185 version = "1.4.49.1000";
188 url = "https://s3.amazonaws.com/redshift-downloads/drivers/odbc/${version}/AmazonRedshiftODBC-64-bit-${version}-1.x86_64.deb";
189 sha256 = "sha256-r5HvsZjB7+x+ClxtWoONkE1/NAbz90NbHfzxC6tf7jA=";
192 nativeBuildInputs = [ dpkg ];
199 # `unixODBC` is loaded with `dlopen`, so `autoPatchElfHook` cannot see it, and `patchELF` phase would strip the manual patchelf. Thus:
200 # - Manually patchelf with `unixODCB` libraries
201 # - Disable automatic `patchELF` phase
204 cp opt/amazon/redshiftodbc/lib/64/* $out/lib
205 patchelf --set-rpath ${unixODBC}/lib/ $out/lib/libamazonredshiftodbc64.so
210 buildInputs = [ unixODBC ];
213 fancyName = "Amazon Redshift (x64)";
214 driver = "lib/libamazonredshiftodbc64.so";
218 broken = stdenv.isDarwin;
219 description = "Amazon Redshift ODBC driver";
220 homepage = "https://docs.aws.amazon.com/redshift/latest/mgmt/configure-odbc-connection.html";
221 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
222 license = licenses.unfree;
223 platforms = platforms.linux;
224 maintainers = with maintainers; [ sir4ur0n ];