From ae0d5d9cc8dd82af36846bc3a4839ae16f98a6df Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 4 Aug 2024 22:28:49 +0200 Subject: [PATCH] unixODBCDrivers.psql: merge with psqlodbc The former hasn't been updated in years and broke with the upgrade of `pkgs.postgresql` to v16 subsequently breaking `qtbase`[1]. There's already `pkgs.psqlodbc` which seems to be the same, but kept up-to-date and linked against libiodbc. Modify `pkgs.psqlodbc` to provide both libiodbc and unixodbc variants. [1] https://github.com/NixOS/nixpkgs/pull/329611#issuecomment-2267513284 --- .../libraries/psqlodbc/default.nix | 25 +++++++++++++---- .../libraries/unixODBCDrivers/default.nix | 27 ++----------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/pkgs/development/libraries/psqlodbc/default.nix b/pkgs/development/libraries/psqlodbc/default.nix index 946cb5035935..0431bb284dab 100644 --- a/pkgs/development/libraries/psqlodbc/default.nix +++ b/pkgs/development/libraries/psqlodbc/default.nix @@ -1,4 +1,9 @@ -{ lib, stdenv, fetchurl, libiodbc, postgresql, openssl }: +{ lib, stdenv, fetchurl, postgresql, openssl +, withLibiodbc ? false, libiodbc +, withUnixODBC ? true, unixODBC +}: + +assert lib.xor withLibiodbc withUnixODBC; stdenv.mkDerivation rec { pname = "psqlodbc"; @@ -9,18 +14,28 @@ stdenv.mkDerivation rec { hash = "sha256-r9iS+J0uzujT87IxTxvVvy0CIBhyxuNDHlwxCW7KTIs="; }; - buildInputs = [ libiodbc postgresql openssl ]; + buildInputs = [ + postgresql + openssl + ] + ++ lib.optional withLibiodbc libiodbc + ++ lib.optional withUnixODBC unixODBC; + + passthru = lib.optionalAttrs withUnixODBC { + fancyName = "PostgreSQL"; + driver = "lib/psqlodbcw.so"; + }; configureFlags = [ - "--with-iodbc=${libiodbc}" "--with-libpq=${lib.getDev postgresql}/bin/pg_config" - ]; + ] + ++ lib.optional withLibiodbc "--with-iodbc=${libiodbc}"; meta = with lib; { homepage = "https://odbc.postgresql.org/"; description = "ODBC driver for PostgreSQL"; license = licenses.lgpl2; - platforms = platforms.linux; + platforms = platforms.unix; maintainers = [ ]; }; } diff --git a/pkgs/development/libraries/unixODBCDrivers/default.nix b/pkgs/development/libraries/unixODBCDrivers/default.nix index 641d051c1c32..fe181d37f6bf 100644 --- a/pkgs/development/libraries/unixODBCDrivers/default.nix +++ b/pkgs/development/libraries/unixODBCDrivers/default.nix @@ -1,4 +1,4 @@ -{ fetchurl, stdenv, unixODBC, cmake, postgresql, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, libkrb5, libuuid, patchelf, libiconv, fixDarwinDylibNames, fetchFromGitHub }: +{ fetchurl, stdenv, unixODBC, cmake, mariadb, sqlite, zlib, libxml2, dpkg, lib, openssl, libkrb5, libuuid, patchelf, libiconv, fixDarwinDylibNames, fetchFromGitHub, psqlodbc }: # Each of these ODBC drivers can be configured in your odbcinst.ini file using # the various passthru and meta values. Of note are: @@ -16,30 +16,7 @@ # '' { - psql = stdenv.mkDerivation rec { - pname = "psqlodbc"; - version = "10.01.0000"; - - src = fetchurl { - url = "mirror://postgresql/odbc/versions/src/${pname}-${version}.tar.gz"; - sha256 = "1cyams7157f3gry86x64xrplqi2vyqrq3rqka59gv4lb4rpl7jl7"; - }; - - buildInputs = [ unixODBC postgresql ]; - - # see the top of the file for an explanation - passthru = { - fancyName = "PostgreSQL"; - driver = "lib/psqlodbcw.so"; - }; - - meta = with lib; { - description = "Official PostgreSQL ODBC Driver"; - homepage = "https://odbc.postgresql.org/"; - license = licenses.lgpl2; - platforms = platforms.unix; - }; - }; + psql = psqlodbc.override { withUnixODBC = true; withLibiodbc = false; }; mariadb = stdenv.mkDerivation rec { pname = "mariadb-connector-odbc";