about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/unixODBCDrivers
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-10-20 22:09:03 +0000
committerAlyssa Ross <hi@alyssa.is>2023-10-20 22:09:03 +0000
commit50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e (patch)
treef2556b911180125ccbb7ed0e78a54e92da89adce /nixpkgs/pkgs/development/libraries/unixODBCDrivers
parent4c16d4548a98563c9d9ad76f4e5b2202864ccd54 (diff)
parentcfc75eec4603c06503ae750f88cf397e00796ea8 (diff)
downloadnixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar
nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.gz
nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.bz2
nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.lz
nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.xz
nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.tar.zst
nixlib-50c21d167f7114fa1dbd95e5c4fb30eeb1a2d02e.zip
Merge commit 'cfc75eec4603c06503ae750f88cf397e00796ea8'
Conflicts:
	nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/unixODBCDrivers')
-rw-r--r--nixpkgs/pkgs/development/libraries/unixODBCDrivers/default.nix122
-rw-r--r--nixpkgs/pkgs/development/libraries/unixODBCDrivers/mariadb-connector-odbc-unistd.patch12
2 files changed, 128 insertions, 6 deletions
diff --git a/nixpkgs/pkgs/development/libraries/unixODBCDrivers/default.nix b/nixpkgs/pkgs/development/libraries/unixODBCDrivers/default.nix
index d29ea557b1f2..e692d58a7c86 100644
--- a/nixpkgs/pkgs/development/libraries/unixODBCDrivers/default.nix
+++ b/nixpkgs/pkgs/development/libraries/unixODBCDrivers/default.nix
@@ -1,6 +1,19 @@
-{ fetchurl, stdenv, unixODBC, cmake, postgresql, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, libkrb5, libuuid, patchelf, libiconv, fetchFromGitHub }:
-
-# I haven't done any parameter tweaking.. So the defaults provided here might be bad
+{ fetchurl, stdenv, unixODBC, cmake, postgresql, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, libkrb5, libuuid, patchelf, libiconv, fixDarwinDylibNames, fetchFromGitHub }:
+
+# Each of these ODBC drivers can be configured in your odbcinst.ini file using
+# the various passthru and meta values. Of note are:
+#
+#   * `passthru.fancyName`, the typical name used to reference the driver
+#   * `passthru.driver`, the path to the driver within the built package
+#   * `meta.description`, a short description of the ODBC driver
+#
+# For example, you might generate it as follows:
+#
+# ''
+# [${package.fancyName}]
+# Description = ${package.meta.description}
+# Driver = ${package}/${package.driver}
+# ''
 
 {
   psql = stdenv.mkDerivation rec {
@@ -14,6 +27,7 @@
 
     buildInputs = [ unixODBC postgresql ];
 
+    # see the top of the file for an explanation
     passthru = {
       fancyName = "PostgreSQL";
       driver = "lib/psqlodbcw.so";
@@ -41,8 +55,14 @@
       fetchSubmodules = true;
     };
 
+    patches = [
+      # Fix `call to undeclared function 'sleep'` with clang 16
+      ./mariadb-connector-odbc-unistd.patch
+    ];
+
     nativeBuildInputs = [ cmake ];
-    buildInputs = [ unixODBC openssl libiconv ];
+    buildInputs = [ unixODBC openssl libiconv zlib ]
+      ++ lib.optionals stdenv.isDarwin [ libkrb5 ];
 
     preConfigure = ''
       # we don't want to build a .pkg
@@ -52,6 +72,7 @@
     '';
 
     cmakeFlags = [
+      "-DWITH_EXTERNAL_ZLIB=ON"
       "-DODBC_LIB_DIR=${lib.getLib unixODBC}/lib"
       "-DODBC_INCLUDE_DIR=${lib.getDev unixODBC}/include"
       "-DWITH_OPENSSL=ON"
@@ -59,6 +80,7 @@
       "-DWITH_IODBC=OFF"
     ];
 
+    # see the top of the file for an explanation
     passthru = {
       fancyName = "MariaDB";
       driver = "lib/libmaodbc${stdenv.hostPlatform.extensions.sharedLibrary}";
@@ -87,6 +109,7 @@
 
     cmakeFlags = [ "-DWITH_UNIXODBC=1" ];
 
+    # see the top of the file for an explanation
     passthru = {
       fancyName = "MySQL";
       driver = "lib/libmyodbc3-3.51.12.so";
@@ -122,6 +145,7 @@
       mv "$out"/*.* "$out/lib"
     '';
 
+    # see the top of the file for an explanation
     passthru = {
       fancyName = "SQLite";
       driver = "lib/libsqlite3odbc.so";
@@ -165,14 +189,15 @@
         $out/lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}
     '';
 
+    # see the top of the file for an explanation
     passthru = {
-      fancyName = "ODBC Driver 17 for SQL Server";
+      fancyName = "ODBC Driver ${versionMajor} for SQL Server";
       driver = "lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}";
     };
 
     meta = with lib; {
       broken = stdenv.isDarwin;
-      description = "ODBC Driver 17 for SQL Server";
+      description = "ODBC Driver ${versionMajor} for SQL Server";
       homepage = "https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017";
       sourceProvenance = with sourceTypes; [ binaryNativeCode ];
       license = licenses.unfree;
@@ -181,6 +206,90 @@
     };
   };
 
+  msodbcsql18 = stdenv.mkDerivation(finalAttrs: {
+    pname = "msodbcsql${finalAttrs.versionMajor}";
+    version = "${finalAttrs.versionMajor}.${finalAttrs.versionMinor}.${finalAttrs.versionAdditional}${finalAttrs.versionSuffix}";
+
+    versionMajor = "18";
+    versionMinor = "1";
+    versionAdditional = "1.1";
+    versionSuffix = lib.optionalString stdenv.isLinux "-1";
+
+    src = fetchurl {
+      url = {
+        x86_64-linux = "https://packages.microsoft.com/debian/11/prod/pool/main/m/${finalAttrs.pname}/${finalAttrs.pname}_${finalAttrs.version}_amd64.deb";
+        aarch64-linux = "https://packages.microsoft.com/debian/11/prod/pool/main/m/${finalAttrs.pname}/${finalAttrs.pname}_${finalAttrs.version}_arm64.deb";
+        x86_64-darwin = "https://download.microsoft.com/download/6/4/0/64006503-51e3-44f0-a6cd-a9b757d0d61b/${finalAttrs.pname}-${finalAttrs.version}-amd64.tar.gz";
+        aarch64-darwin = "https://download.microsoft.com/download/6/4/0/64006503-51e3-44f0-a6cd-a9b757d0d61b/${finalAttrs.pname}-${finalAttrs.version}-arm64.tar.gz";
+      }.${stdenv.system} or (throw "Unsupported platform");
+      hash = {
+        x86_64-linux = "sha256:1f0rmh1aynf1sqmjclbsyh2wz5jby0fixrwz71zp6impxpwvil52";
+        aarch64-linux = "sha256:0zphnbvkqdbkcv6lvv63p7pyl68h5bs2dy6vv44wm6bi89svms4a";
+        x86_64-darwin = "sha256:1fn80byn1yihflznxcm9cpj42mpllnz54apnk9n46vzm2ng2lj6d";
+        aarch64-darwin = "sha256:116xl8r2apr5b48jnq6myj9fwqs88yccw5176yfyzh4534fznj5x";
+      }.${stdenv.system} or (throw "Unsupported platform");
+    };
+
+    nativeBuildInputs =
+      if stdenv.isDarwin
+      then
+        [
+          # Fix up the names encoded into the dylib, and make them absolute.
+          fixDarwinDylibNames
+        ]
+      else
+        [
+          dpkg
+          patchelf
+        ];
+
+    unpackPhase = lib.optionalString stdenv.isLinux ''
+      dpkg -x $src ./
+    '';
+
+    installPhase =
+      if stdenv.isDarwin
+      then
+        ''
+          mkdir -p $out
+          tar xf $src --strip-components=1 -C $out
+        ''
+      else
+        ''
+          mkdir -p $out
+          mkdir -p $out/lib
+          cp -r opt/microsoft/msodbcsql${finalAttrs.versionMajor}/lib64 opt/microsoft/msodbcsql${finalAttrs.versionMajor}/share $out/
+        '';
+
+    # Replace the hard-coded paths in the dylib with nixpkgs equivalents.
+    fixupPhase = lib.optionalString stdenv.isDarwin ''
+      ${stdenv.cc.bintools.targetPrefix}install_name_tool \
+        -change /usr/lib/libiconv.2.dylib ${libiconv}/lib/libiconv.2.dylib \
+        -change /opt/homebrew/lib/libodbcinst.2.dylib ${unixODBC}/lib/libodbcinst.2.dylib \
+        $out/${finalAttrs.passthru.driver}
+    '';
+
+    postFixup = lib.optionalString stdenv.isLinux ''
+      patchelf --set-rpath ${lib.makeLibraryPath [ unixODBC openssl libkrb5 libuuid stdenv.cc.cc ]} \
+        $out/${finalAttrs.passthru.driver}
+    '';
+
+    # see the top of the file for an explanation
+    passthru = {
+      fancyName = "ODBC Driver ${finalAttrs.versionMajor} for SQL Server";
+      driver = "lib/libmsodbcsql${if stdenv.isDarwin then ".${finalAttrs.versionMajor}.dylib" else "-${finalAttrs.versionMajor}.${finalAttrs.versionMinor}.so.${finalAttrs.versionAdditional}"}";
+    };
+
+    meta = with lib; {
+      description = finalAttrs.passthru.fancyName;
+      homepage = "https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16";
+      sourceProvenance = with sourceTypes; [ binaryNativeCode ];
+      platforms = platforms.unix;
+      license = licenses.unfree;
+      maintainers = with maintainers; [ SamirTalwar ];
+    };
+  });
+
   redshift = stdenv.mkDerivation rec {
     pname = "redshift-odbc";
     version = "1.4.49.1000";
@@ -210,6 +319,7 @@
 
     buildInputs = [ unixODBC ];
 
+    # see the top of the file for an explanation
     passthru = {
       fancyName = "Amazon Redshift (x64)";
       driver = "lib/libamazonredshiftodbc64.so";
diff --git a/nixpkgs/pkgs/development/libraries/unixODBCDrivers/mariadb-connector-odbc-unistd.patch b/nixpkgs/pkgs/development/libraries/unixODBCDrivers/mariadb-connector-odbc-unistd.patch
new file mode 100644
index 000000000000..8c976885eb62
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/unixODBCDrivers/mariadb-connector-odbc-unistd.patch
@@ -0,0 +1,12 @@
+diff -ur a/test/use_result.c b/test/use_result.c
+--- a/test/use_result.c	1969-12-31 19:00:01.000000000 -0500
++++ b/test/use_result.c	2023-09-05 00:08:12.979889343 -0400
+@@ -23,6 +23,8 @@
+   51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+ 
++#include <unistd.h>
++
+ #include "tap.h"
+ 
+ SQLINTEGER my_max_rows= 100;