python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / unixODBCDrivers / default.nix
blob1e5149683d4cc01399e2e6dd8c72875ba849492a
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 {
7     pname = "psqlodbc";
8     version = "10.01.0000";
10     src = fetchurl {
11       url = "mirror://postgresql/odbc/versions/src/${pname}-${version}.tar.gz";
12       sha256 = "1cyams7157f3gry86x64xrplqi2vyqrq3rqka59gv4lb4rpl7jl7";
13     };
15     buildInputs = [ unixODBC postgresql ];
17     passthru = {
18       fancyName = "PostgreSQL";
19       driver = "lib/psqlodbcw.so";
20     };
22     meta = with lib; {
23       broken = stdenv.isDarwin;
24       description = "Official PostgreSQL ODBC Driver";
25       homepage = "https://odbc.postgresql.org/";
26       license = licenses.lgpl2;
27       platforms = platforms.linux;
28     };
29   };
31   mariadb = stdenv.mkDerivation rec {
32     pname = "mariadb-connector-odbc";
33     version = "3.1.14";
35     src = fetchFromGitHub {
36       owner = "mariadb-corporation";
37       repo = "mariadb-connector-odbc";
38       rev = version;
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;
43     };
45     nativeBuildInputs = [ cmake ];
46     buildInputs = [ unixODBC openssl libiconv ];
48     preConfigure = ''
49       # we don't want to build a .pkg
50       sed -i 's/ADD_SUBDIRECTORY(osxinstall)//g' CMakeLists.txt
51     '';
53     cmakeFlags = [
54       "-DWITH_OPENSSL=ON"
55       # on darwin this defaults to ON but we want to build against unixODBC
56       "-DWITH_IODBC=OFF"
57     ];
59     passthru = {
60       fancyName = "MariaDB";
61       driver = "lib/libmaodbc${stdenv.hostPlatform.extensions.sharedLibrary}";
62     };
64     meta = with lib; {
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;
70     };
71   };
73   mysql = stdenv.mkDerivation rec {
74     pname = "mysql-connector-odbc";
75     majorVersion = "5.3";
76     version = "${majorVersion}.6";
78     src = fetchurl {
79       url = "https://dev.mysql.com/get/Downloads/Connector-ODBC/${majorVersion}/${pname}-${version}-src.tar.gz";
80       sha256 = "1smi4z49i4zm7cmykjkwlxxzqvn7myngsw5bc35z6gqxmi8c55xr";
81     };
83     nativeBuildInputs = [ cmake ];
84     buildInputs = [ unixODBC mariadb ];
86     cmakeFlags = [ "-DWITH_UNIXODBC=1" ];
88     passthru = {
89       fancyName = "MySQL";
90       driver = "lib/libmyodbc3-3.51.12.so";
91     };
93     meta = with lib; {
94       description = "MySQL ODBC database driver";
95       homepage = "https://dev.mysql.com/downloads/connector/odbc/";
96       license = licenses.gpl2;
97       platforms = platforms.linux;
98       broken = true;
99     };
100   };
102   sqlite = stdenv.mkDerivation rec {
103     pname = "sqlite-connector-odbc";
104     version = "0.9993";
106     src = fetchurl {
107       url = "http://www.ch-werner.de/sqliteodbc/sqliteodbc-${version}.tar.gz";
108       sha256 = "0dgsj28sc7f7aprmdd0n5a1rmcx6pv7170c8dfjl0x1qsjxim6hs";
109     };
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
118     postInstall = ''
119       mkdir -p "$out/lib"
120       mv "$out"/*.* "$out/lib"
121     '';
123     passthru = {
124       fancyName = "SQLite";
125       driver = "lib/libsqlite3odbc.so";
126     };
128     meta = with lib; {
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 ];
135     };
136   };
138   msodbcsql17 = stdenv.mkDerivation rec {
139     pname = "msodbcsql17";
140     version = "${versionMajor}.${versionMinor}.${versionAdditional}-1";
142     versionMajor = "17";
143     versionMinor = "7";
144     versionAdditional = "1.1";
146     src = fetchurl {
147       url = "https://packages.microsoft.com/debian/10/prod/pool/main/m/msodbcsql17/msodbcsql${versionMajor}_${version}_amd64.deb";
148       sha256 = "0vwirnp56jibm3qf0kmi4jnz1w7xfhnsfr8imr0c9hg6av4sk3a6";
149     };
151     nativeBuildInputs = [ dpkg patchelf ];
153     unpackPhase = "dpkg -x $src ./";
154     buildPhase = "";
156     installPhase = ''
157       mkdir -p $out
158       mkdir -p $out/lib
159       cp -r opt/microsoft/msodbcsql${versionMajor}/lib64 opt/microsoft/msodbcsql${versionMajor}/share $out/
160     '';
162     postFixup = ''
163       patchelf --set-rpath ${lib.makeLibraryPath [ unixODBC openssl libkrb5 libuuid stdenv.cc.cc ]} \
164         $out/lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}
165     '';
167     passthru = {
168       fancyName = "ODBC Driver 17 for SQL Server";
169       driver = "lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}";
170     };
172     meta = with lib; {
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 ];
180     };
181   };
183   redshift = stdenv.mkDerivation rec {
184     pname = "redshift-odbc";
185     version = "1.4.49.1000";
187     src = fetchurl {
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=";
190     };
192     nativeBuildInputs = [ dpkg ];
194     unpackPhase = ''
195       dpkg -x $src src
196       cd src
197     '';
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
202     installPhase = ''
203       mkdir -p $out/lib
204       cp opt/amazon/redshiftodbc/lib/64/* $out/lib
205       patchelf --set-rpath ${unixODBC}/lib/ $out/lib/libamazonredshiftodbc64.so
206     '';
208     dontPatchELF = true;
210     buildInputs = [ unixODBC ];
212     passthru = {
213       fancyName = "Amazon Redshift (x64)";
214       driver = "lib/libamazonredshiftodbc64.so";
215     };
217     meta = with lib; {
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 ];
225     };
226   };