2021-01-15 07:07:56 +00:00
|
|
|
{ lib, stdenv, fetchurl, cmake
|
2019-09-22 08:38:09 +01:00
|
|
|
, curl, openssl, zlib
|
|
|
|
, libiconv
|
|
|
|
, version, sha256, ...
|
|
|
|
}:
|
|
|
|
|
2021-01-15 07:07:56 +00:00
|
|
|
with lib;
|
2019-09-22 08:38:09 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "mariadb-connector-c";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
urls = [
|
|
|
|
"https://downloads.mariadb.org/f/connector-c-${version}/mariadb-connector-c-${version}-src.tar.gz"
|
|
|
|
"https://downloads.mariadb.com/Connectors/c/connector-c-${version}/mariadb-connector-c-${version}-src.tar.gz"
|
|
|
|
];
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2020-09-06 15:06:25 +01:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2019-09-22 08:38:09 +01:00
|
|
|
cmakeFlags = [
|
2019-09-29 12:03:05 +01:00
|
|
|
"-DMARIADB_UNIX_ADDR=/run/mysqld/mysqld.sock"
|
2019-09-22 08:38:09 +01:00
|
|
|
"-DWITH_CURL=ON"
|
2019-10-23 08:01:04 +01:00
|
|
|
"-DWITH_EXTERNAL_ZLIB=ON"
|
|
|
|
"-DWITH_MYSQLCOMPAT=ON"
|
2019-09-22 08:38:09 +01:00
|
|
|
];
|
|
|
|
|
2020-09-06 15:06:25 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace mariadb_config/mariadb_config.c.in \
|
|
|
|
--replace '@CMAKE_SYSROOT@@CMAKE_INSTALL_PREFIX@/@INSTALL_INCLUDEDIR@' "$dev/include" \
|
|
|
|
--replace '@CMAKE_SYSROOT@@CMAKE_INSTALL_PREFIX@/@INSTALL_LIBDIR@' "$out/lib/mariadb"
|
|
|
|
'';
|
|
|
|
|
2019-09-22 08:38:09 +01:00
|
|
|
# The cmake setup-hook uses $out/lib by default, this is not the case here.
|
|
|
|
preConfigure = optionalString stdenv.isDarwin ''
|
|
|
|
cmakeFlagsArray+=("-DCMAKE_INSTALL_NAME_DIR=$out/lib/mariadb")
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
propagatedBuildInputs = [ curl openssl zlib ];
|
|
|
|
buildInputs = [ libiconv ];
|
|
|
|
|
2020-09-06 15:06:25 +01:00
|
|
|
postInstall = ''
|
|
|
|
moveToOutput bin/mariadb_config "$dev"
|
|
|
|
'';
|
|
|
|
|
2019-09-22 08:38:09 +01:00
|
|
|
postFixup = ''
|
2020-09-06 15:06:25 +01:00
|
|
|
ln -sv mariadb_config $dev/bin/mysql_config
|
2019-09-22 08:38:09 +01:00
|
|
|
ln -sv mariadb $out/lib/mysql
|
2020-09-06 15:06:25 +01:00
|
|
|
ln -sv mariadb $dev/include/mysql
|
|
|
|
ln -sv mariadb_version.h $dev/include/mariadb/mysql_version.h
|
|
|
|
ln -sv libmariadb.pc $dev/lib/pkgconfig/mysqlclient.pc
|
2019-09-22 08:38:09 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Client library that can be used to connect to MySQL or MariaDB";
|
|
|
|
license = licenses.lgpl21;
|
|
|
|
maintainers = with maintainers; [ globin ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|