nixpkgs/pkgs/servers/sql/mariadb/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

265 lines
9.4 KiB
Nix
Raw Normal View History

2022-01-23 11:58:35 +01:00
{ lib, stdenv, fetchurl, nixosTests, buildPackages
2021-11-16 08:53:46 +01:00
# Native buildInputs components
, bison, boost, cmake, fixDarwinDylibNames, flex, makeWrapper, pkg-config
# Common components
2021-12-08 10:46:40 +01:00
, curl, libiconv, ncurses, openssl, pcre, pcre2
, libkrb5, libaio, liburing, systemd
2021-11-16 08:53:46 +01:00
, CoreServices, cctools, perl
2022-02-17 16:04:33 +01:00
, jemalloc, less, libedit
2021-11-16 08:53:46 +01:00
# Server components
2020-04-02 09:22:10 +02:00
, bzip2, lz4, lzo, snappy, xz, zlib, zstd
2021-11-16 08:53:46 +01:00
, cracklib, judy, libevent, libxml2
, linux-pam, numactl, pmdk
, fmt_8
, withStorageMroonga ? true, kytea, libsodium, msgpack, zeromq
, withStorageRocks ? true
2015-03-11 22:12:00 +01:00
}:
2014-02-24 21:34:57 +01:00
2022-02-17 16:04:33 +01:00
let
libExt = stdenv.hostPlatform.extensions.sharedLibrary;
2022-01-23 11:58:35 +01:00
mytopEnv = buildPackages.perl.withPackages (p: with p; [ DBDmysql DBI TermReadKey ]);
2019-07-11 04:49:51 +02:00
2021-12-08 10:46:40 +01:00
mariadbPackage = packageSettings: (server packageSettings) // {
client = client packageSettings; # MariaDB Client
server = server packageSettings; # MariaDB Server
};
2021-12-08 10:46:40 +01:00
commonOptions = packageSettings: rec { # attributes common to both builds
inherit (packageSettings) version;
src = fetchurl {
url = "https://downloads.mariadb.com/MariaDB/mariadb-${version}/source/mariadb-${version}.tar.gz";
2021-12-08 10:46:40 +01:00
inherit (packageSettings) sha256;
2014-02-24 21:34:57 +01:00
};
nativeBuildInputs = [ cmake pkg-config ]
2021-12-08 10:46:40 +01:00
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames
++ lib.optional (!stdenv.hostPlatform.isDarwin) makeWrapper;
2017-12-21 09:32:59 +01:00
2017-07-29 23:34:16 +02:00
buildInputs = [
2021-12-08 10:46:40 +01:00
curl libiconv ncurses openssl zlib
] ++ (packageSettings.extraBuildInputs or [])
++ lib.optionals stdenv.hostPlatform.isLinux ([ libkrb5 systemd ]
++ (if (lib.versionOlder version "10.6") then [ libaio ] else [ liburing ]))
2022-02-17 16:04:33 +01:00
++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices cctools perl libedit ]
2021-12-08 10:46:40 +01:00
++ lib.optional (!stdenv.hostPlatform.isDarwin) [ jemalloc ]
++ (if (lib.versionOlder version "10.5") then [ pcre ] else [ pcre2 ]);
2017-07-29 23:34:16 +02:00
prePatch = ''
sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt
'';
2019-08-01 13:08:45 +02:00
patches = [
2021-11-18 08:46:01 +01:00
./patch/cmake-includedir.patch
2021-11-17 08:45:55 +01:00
]
# Fixes a build issue as documented on
# https://jira.mariadb.org/browse/MDEV-26769?focusedCommentId=206073&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-206073
2021-12-08 10:46:40 +01:00
++ lib.optional (!stdenv.hostPlatform.isLinux && lib.versionAtLeast version "10.6") ./patch/macos-MDEV-26769-regression-fix.patch;
2015-03-11 22:12:00 +01:00
cmakeFlags = [
"-DBUILD_CONFIG=mysql_release"
"-DMANUFACTURER=NixOS.org"
"-DDEFAULT_CHARSET=utf8mb4"
"-DDEFAULT_COLLATION=utf8mb4_unicode_ci"
"-DSECURITY_HARDENED=ON"
2019-05-19 13:35:10 +02:00
"-DINSTALL_UNIX_ADDRDIR=/run/mysqld/mysqld.sock"
"-DINSTALL_BINDIR=bin"
"-DINSTALL_DOCDIR=share/doc/mysql"
"-DINSTALL_DOCREADMEDIR=share/doc/mysql"
"-DINSTALL_INCLUDEDIR=include/mysql"
"-DINSTALL_LIBDIR=lib"
2019-08-01 13:08:45 +02:00
"-DINSTALL_PLUGINDIR=lib/mysql/plugin"
2019-05-19 13:35:10 +02:00
"-DINSTALL_INFODIR=share/mysql/docs"
"-DINSTALL_MANDIR=share/man"
"-DINSTALL_MYSQLSHAREDIR=share/mysql"
2019-05-19 13:35:10 +02:00
"-DINSTALL_SCRIPTDIR=bin"
"-DINSTALL_SUPPORTFILESDIR=share/doc/mysql"
"-DINSTALL_MYSQLTESTDIR=OFF"
"-DINSTALL_SQLBENCHDIR=OFF"
"-DINSTALL_PAMDIR=share/pam/lib/security"
"-DINSTALL_PAMDATADIR=share/pam/etc/security"
"-DWITH_ZLIB=system"
"-DWITH_SSL=system"
"-DWITH_PCRE=system"
2019-05-19 13:35:10 +02:00
"-DWITH_SAFEMALLOC=OFF"
2019-08-01 13:22:10 +02:00
"-DWITH_UNIT_TESTS=OFF"
2019-05-19 13:35:10 +02:00
"-DEMBEDDED_LIBRARY=OFF"
2021-12-08 10:46:40 +01:00
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
# On Darwin without sandbox, CMake will find the system java and attempt to build with java support, but
# then it will fail during the actual build. Let's just disable the flag explicitly until someone decides
2019-05-19 13:35:10 +02:00
# to pass in java explicitly.
"-DCONNECT_WITH_JDBC=OFF"
2019-05-19 13:35:10 +02:00
"-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib"
];
2019-08-01 13:08:45 +02:00
postInstall = ''
2019-10-10 16:53:48 +02:00
# Remove Development components. Need to use libmysqlclient.
2019-08-01 13:25:45 +02:00
rm "$out"/lib/mysql/plugin/daemon_example.ini
2019-10-10 16:53:48 +02:00
rm "$out"/lib/{libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a}
2021-12-08 10:46:40 +01:00
rm -f "$out"/bin/{mariadb-config,mariadb_config,mysql_config}
2019-10-10 16:53:48 +02:00
rm -r $out/include
rm -r $out/lib/pkgconfig
2019-08-01 13:08:45 +02:00
'';
# perlPackages.DBDmysql is broken on darwin
2021-12-08 10:46:40 +01:00
postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
wrapProgram $out/bin/mytop --set PATH ${lib.makeBinPath [ less ncurses ]}
'';
2021-12-08 10:46:40 +01:00
passthru.tests = let
testVersion = "mariadb_${builtins.replaceStrings ["."] [""] (lib.versions.majorMinor (packageSettings.version))}";
in {
mariadb-galera-rsync = nixosTests.mariadb-galera.${testVersion};
2021-12-08 10:46:40 +01:00
mysql = nixosTests.mysql.${testVersion};
mysql-autobackup = nixosTests.mysql-autobackup.${testVersion};
mysql-backup = nixosTests.mysql-backup.${testVersion};
mysql-replication = nixosTests.mysql-replication.${testVersion};
};
2021-12-08 10:46:40 +01:00
meta = with lib; {
description = "An enhanced, drop-in replacement for MySQL";
homepage = "https://mariadb.org/";
license = licenses.gpl2;
2021-12-08 10:46:40 +01:00
maintainers = with maintainers; [ thoughtpolice ajs124 das_j ];
platforms = platforms.all;
};
};
2021-12-08 10:46:40 +01:00
client = packageSettings: let
common = commonOptions packageSettings;
in stdenv.mkDerivation (common // {
2019-08-01 13:01:56 +02:00
pname = "mariadb-client";
2019-10-10 16:53:48 +02:00
outputs = [ "out" "man" ];
patches = common.patches ++ [
2021-11-18 08:46:01 +01:00
./patch/cmake-plugin-includedir.patch
];
2019-05-19 14:15:32 +02:00
cmakeFlags = common.cmakeFlags ++ [
"-DPLUGIN_AUTH_PAM=NO"
"-DWITHOUT_SERVER=ON"
2019-05-19 13:40:53 +02:00
"-DWITH_WSREP=OFF"
"-DINSTALL_MYSQLSHAREDIR=share/mysql-client"
];
postInstall = common.postInstall + ''
rm "$out"/bin/{mariadb-test,mysqltest}
libmysqlclient_path=$(readlink -f $out/lib/libmysqlclient${libExt})
rm "$out"/lib/{libmariadb${libExt},libmysqlclient${libExt},libmysqlclient_r${libExt}}
mv "$libmysqlclient_path" "$out"/lib/libmysqlclient${libExt}
ln -sv libmysqlclient${libExt} "$out"/lib/libmysqlclient_r${libExt}
'';
});
2021-12-08 10:46:40 +01:00
server = packageSettings: let
common = commonOptions packageSettings;
in stdenv.mkDerivation (common // {
pname = "mariadb-server";
2019-10-10 16:53:48 +02:00
outputs = [ "out" "man" ];
2019-05-19 13:35:10 +02:00
2021-11-16 08:53:46 +01:00
nativeBuildInputs = common.nativeBuildInputs ++ [ bison boost.dev flex ];
buildInputs = common.buildInputs ++ [
2020-04-02 09:22:10 +02:00
bzip2 lz4 lzo snappy xz zstd
2021-11-16 08:53:46 +01:00
cracklib judy libevent libxml2
2021-12-08 10:46:40 +01:00
] ++ lib.optional (stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32) numactl
++ lib.optionals stdenv.hostPlatform.isLinux [ linux-pam ]
++ lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64) pmdk.dev
++ lib.optional (!stdenv.hostPlatform.isDarwin) mytopEnv
++ lib.optionals withStorageMroonga [ kytea libsodium msgpack zeromq ]
++ lib.optionals (lib.versionAtLeast common.version "10.7") [ fmt_8 ];
2020-08-11 11:47:07 +02:00
patches = common.patches;
postPatch = ''
substituteInPlace scripts/galera_new_cluster.sh \
--replace ":-mariadb" ":-mysql"
'';
cmakeFlags = common.cmakeFlags ++ [
2015-03-11 22:12:00 +01:00
"-DMYSQL_DATADIR=/var/lib/mysql"
2019-05-19 13:35:10 +02:00
"-DENABLED_LOCAL_INFILE=OFF"
2015-03-11 22:12:00 +01:00
"-DWITH_READLINE=ON"
2019-05-19 13:35:10 +02:00
"-DWITH_EXTRA_CHARSETS=all"
"-DWITH_EMBEDDED_SERVER=OFF"
"-DWITH_UNIT_TESTS=OFF"
"-DWITH_WSREP=ON"
2017-12-29 18:28:53 +01:00
"-DWITH_INNODB_DISALLOW_WRITES=ON"
2019-05-19 13:35:10 +02:00
"-DWITHOUT_EXAMPLE=1"
"-DWITHOUT_FEDERATED=1"
"-DWITHOUT_TOKUDB=1"
2021-12-08 10:46:40 +01:00
] ++ lib.optional (stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAarch32) [
2020-02-06 12:25:28 +01:00
"-DWITH_NUMA=ON"
2021-12-08 10:46:40 +01:00
] ++ lib.optional (!withStorageMroonga) [
"-DWITHOUT_MROONGA=1"
2021-12-08 10:46:40 +01:00
] ++ lib.optional (!withStorageRocks) [
"-DWITHOUT_ROCKSDB=1"
2021-12-08 10:46:40 +01:00
] ++ lib.optional (!stdenv.hostPlatform.isDarwin && withStorageRocks) [
"-DWITH_ROCKSDB_JEMALLOC=ON"
2021-12-08 10:46:40 +01:00
] ++ lib.optional (!stdenv.hostPlatform.isDarwin) [
2020-07-01 16:04:34 +02:00
"-DWITH_JEMALLOC=yes"
2021-12-08 10:46:40 +01:00
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"-DPLUGIN_AUTH_PAM=NO"
"-DPLUGIN_AUTH_PAM_V1=NO"
"-DWITHOUT_OQGRAPH=1"
"-DWITHOUT_PLUGIN_S3=1"
2022-01-23 11:58:35 +01:00
] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
# revisit this if nixpkgs supports any architecture whose stack grows upwards
"-DSTACK_DIRECTION=-1"
"-DCMAKE_CROSSCOMPILING_EMULATOR=${stdenv.hostPlatform.emulator buildPackages}"
2015-06-19 08:47:08 +02:00
];
2014-02-24 21:34:57 +01:00
2021-12-08 10:46:40 +01:00
preConfigure = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
2019-07-11 04:49:51 +02:00
patchShebangs scripts/mytop.sh
2019-05-19 13:35:10 +02:00
'';
2019-08-01 13:08:45 +02:00
postInstall = common.postInstall + ''
2021-11-16 08:53:46 +01:00
rm -r "$out"/share/aclocal
2019-05-19 13:35:10 +02:00
chmod +x "$out"/bin/wsrep_sst_common
2021-12-08 10:46:40 +01:00
rm -f "$out"/bin/{mariadb-client-test,mariadb-test,mysql_client_test,mysqltest}
'' + lib.optionalString withStorageMroonga ''
2020-02-06 14:33:59 +01:00
mv "$out"/share/{groonga,groonga-normalizer-mysql} "$out"/share/doc/mysql
2021-12-08 10:46:40 +01:00
'' + lib.optionalString (!stdenv.hostPlatform.isDarwin && lib.versionAtLeast common.version "10.4") ''
mv "$out"/OFF/suite/plugins/pam/pam_mariadb_mtr.so "$out"/share/pam/lib/security
mv "$out"/OFF/suite/plugins/pam/mariadb_mtr "$out"/share/pam/etc/security
rm -r "$out"/OFF
'';
2017-07-30 22:08:19 +02:00
2021-12-08 10:46:40 +01:00
CXXFLAGS = lib.optionalString stdenv.hostPlatform.isi686 "-fpermissive";
});
2021-12-08 10:46:40 +01:00
in {
mariadb_104 = mariadbPackage {
# Supported until 2024-06-18
2022-02-14 22:45:37 +01:00
version = "10.4.24";
sha256 = "0ipqilri8isn0mfvwg8imwf36zm3jsw0wf2yx905c2bznd8mb5zy";
2021-12-08 10:46:40 +01:00
};
mariadb_105 = mariadbPackage {
# Supported until 2025-06-24
2022-02-14 22:45:47 +01:00
version = "10.5.15";
sha256 = "0nfvyxb157qsbl0d1i5gfzr2hb1nm0iv58f7qcbk5kkhz0vyv049";
2021-12-08 10:46:40 +01:00
};
mariadb_106 = mariadbPackage {
# Supported until 2026-07
2022-02-14 22:45:59 +01:00
version = "10.6.7";
sha256 = "1idjnkjfkjvyr6r899xbiwq9wwbs84cm85mbc725yxjshqghzvkm";
};
mariadb_107 = mariadbPackage {
# Supported until 2023-02
2022-02-14 22:46:12 +01:00
version = "10.7.3";
sha256 = "1m2wa67vvdm61ap8spl18b9vqkmsnq4rfd0248l17jf9zwcnja6s";
};
mariadb_108 = mariadbPackage {
# Supported until 2023-05
2022-02-14 22:46:26 +01:00
version = "10.8.2";
sha256 = "0v4mms3mihylnqlc0ifvwzykah6lkdd39lmxbv5vnhbsh7wggq0l";
2022-02-09 22:23:08 +01:00
};
2021-12-08 10:46:40 +01:00
}