nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 110 lines 3.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 cmake, 7 curl, 8 openssl, 9 zlib, 10 zstd, 11 libiconv, 12 version, 13 hash, 14 ... 15}: 16 17let 18 isVer33 = lib.versionAtLeast version "3.3"; 19 20in 21stdenv.mkDerivation { 22 pname = "mariadb-connector-c"; 23 inherit version; 24 25 src = fetchFromGitHub { 26 owner = "mariadb-corporation"; 27 repo = "mariadb-connector-c"; 28 rev = "v${version}"; 29 inherit hash; 30 }; 31 32 patches = lib.optionals (lib.versionOlder version "3.4") [ 33 # fix compilation against gcc15 34 (fetchpatch { 35 url = "https://github.com/mariadb-corporation/mariadb-connector-c/commit/e8448137f3365568090d5c0d4051039ddc1cdb6f.patch"; 36 hash = "sha256-aDbaaJA8DxGG5RrOa+CHhk4wuzlBy5tWyS+f/zVYU0c="; 37 }) 38 39 # Fix the build with CMake 4. 40 (fetchpatch { 41 name = "mariadb-connector-c-fix-cmake-4.patch"; 42 url = "https://github.com/mariadb-corporation/mariadb-connector-c/commit/598dc3d2d7a63e5d250421dd0ea88be55ea8511f.patch"; 43 hash = "sha256-HojNRobguBmtpEdr2lVi/MpcoDAsZnb3+tw/pt376es="; 44 }) 45 ]; 46 47 outputs = [ 48 "out" 49 "dev" 50 ]; 51 52 cmakeFlags = [ 53 "-DMARIADB_UNIX_ADDR=/run/mysqld/mysqld.sock" 54 "-DWITH_CURL=ON" 55 "-DWITH_EXTERNAL_ZLIB=ON" 56 "-DWITH_MYSQLCOMPAT=ON" 57 ]; 58 59 postPatch = '' 60 substituteInPlace mariadb_config/mariadb_config.c.in \ 61 --replace-fail '#define INCLUDE "-I%s/@INSTALL_INCLUDEDIR@ -I%s/@INSTALL_INCLUDEDIR@/mysql"' "#define INCLUDE \"-I$dev/include -I$dev/include/mysql\"" \ 62 --replace-fail '#define LIBS "-L%s/@INSTALL_LIBDIR@/ -lmariadb"' "#define LIBS \"-L$out/lib/mariadb -lmariadb\"" \ 63 --replace-fail '#define PKG_LIBDIR "%s/@INSTALL_LIBDIR@"' "#define PKG_LIBDIR \"$out/lib/mariadb\"" \ 64 --replace-fail '#define PLUGIN_DIR "%s/@INSTALL_PLUGINDIR@"' "#define PLUGIN_DIR \"$out/lib/mariadb/plugin\"" \ 65 --replace-fail '#define PKG_PLUGINDIR "%s/@INSTALL_PLUGINDIR@"' "#define PKG_PLUGINDIR \"$out/lib/mariadb/plugin\"" 66 '' 67 + lib.optionalString stdenv.hostPlatform.isStatic '' 68 # Disables all dynamic plugins 69 substituteInPlace cmake/plugins.cmake \ 70 --replace-fail 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "DYNAMIC")' 'if(''${CC_PLUGIN_DEFAULT} STREQUAL "INVALID")' 71 # Force building static libraries 72 substituteInPlace libmariadb/CMakeLists.txt \ 73 --replace-fail 'libmariadb SHARED' 'libmariadb STATIC' 74 ''; 75 76 # The cmake setup-hook uses $out/lib by default, this is not the case here. 77 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin '' 78 cmakeFlagsArray+=("-DCMAKE_INSTALL_NAME_DIR=$out/lib/mariadb") 79 ''; 80 81 nativeBuildInputs = [ cmake ]; 82 propagatedBuildInputs = [ 83 curl 84 openssl 85 zlib 86 ] 87 ++ lib.optional isVer33 zstd; 88 buildInputs = [ libiconv ]; 89 90 postInstall = '' 91 moveToOutput bin/mariadb_config "$dev" 92 ''; 93 94 postFixup = '' 95 ln -sv mariadb_config $dev/bin/mysql_config 96 ln -sv mariadb $out/lib/mysql 97 ln -sv mariadb $dev/include/mysql 98 ln -sv mariadb_version.h $dev/include/mariadb/mysql_version.h 99 ln -sv libmariadb.pc $dev/lib/pkgconfig/mysqlclient.pc 100 install -Dm644 include/ma_config.h $dev/include/mariadb/my_config.h 101 ''; 102 103 meta = { 104 description = "Client library that can be used to connect to MySQL or MariaDB"; 105 homepage = "https://github.com/mariadb-corporation/mariadb-connector-c"; 106 license = lib.licenses.lgpl21Plus; 107 maintainers = [ ]; 108 platforms = lib.platforms.all; 109 }; 110}