1 { lib, stdenv, fetchurl, bison, cmake, pkg-config
2 , boost, icu, libedit, libevent, lz4, ncurses, openssl, perl, protobuf, re2, readline, zlib, zstd, libfido2
3 , numactl, cctools, CoreServices, developer_cmds, libtirpc, rpcsvc-proto, curl, DarwinTools, nixosTests
5 # Percona-specific deps
6 , coreutils, cyrus_sasl, gnumake, openldap
7 # optional: different malloc implementations
8 , withJemalloc ? false, withTcmalloc ? false, jemalloc, gperftools
11 assert !(withJemalloc && withTcmalloc);
14 stdenv.mkDerivation (finalAttrs: {
15 pname = "percona-server_innovation";
19 url = "https://downloads.percona.com/downloads/percona-distribution-mysql-ps/percona-distribution-mysql-ps-${builtins.head (lib.strings.split "-" finalAttrs.version)}/source/tarball/percona-server-${finalAttrs.version}.tar.gz";
20 hash = "sha256-GeuifzqCkStmb4qYa8147XBHvMogYwfsn0FyHdO4WEg";
23 nativeBuildInputs = [ bison cmake pkg-config ]
24 ++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ];
27 ./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
30 ## NOTE: MySQL upstream frequently twiddles the invocations of libtool. When updating, you might proactively grep for libtool references.
32 substituteInPlace cmake/libutils.cmake --replace /usr/bin/libtool libtool
33 substituteInPlace cmake/os/Darwin.cmake --replace /usr/bin/libtool libtool
34 # The rocksdb setup script is called with `env -i` and cannot find anything in PATH.
35 patchShebangs storage/rocksdb/get_rocksdb_files.sh
36 substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace mktemp ${coreutils}/bin/mktemp
37 substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "rm $MKFILE" "${coreutils}/bin/rm $MKFILE"
38 substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "make --" "${gnumake}/bin/make --"
42 boost (curl.override { inherit openssl; }) icu libedit libevent lz4 ncurses openssl protobuf re2 readline zlib
43 zstd libfido2 openldap perl cyrus_sasl
44 ] ++ lib.optionals stdenv.isLinux [
45 numactl libtirpc systemd
46 ] ++ lib.optionals stdenv.isDarwin [
47 cctools CoreServices developer_cmds DarwinTools
49 ++ lib.optional (stdenv.isLinux && withJemalloc) jemalloc
50 ++ lib.optional (stdenv.isLinux && withTcmalloc) gperftools;
52 outputs = [ "out" "static" ];
55 # Percona-specific flags.
58 "-DROCKSDB_DISABLE_AVX2=1"
59 "-DROCKSDB_DISABLE_MARCH_NATIVE=1"
61 # Flags taken from mysql package.
62 "-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin.
63 "-DWITH_ROUTER=OFF" # It may be packaged separately.
64 "-DWITH_SYSTEM_LIBS=ON"
65 "-DWITH_UNIT_TESTS=OFF"
66 "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
67 "-DMYSQL_DATADIR=/var/lib/mysql"
68 "-DINSTALL_INFODIR=share/mysql/docs"
69 "-DINSTALL_MANDIR=share/man"
70 "-DINSTALL_PLUGINDIR=lib/mysql/plugin"
71 "-DINSTALL_INCLUDEDIR=include/mysql"
72 "-DINSTALL_DOCREADMEDIR=share/mysql"
73 "-DINSTALL_SUPPORTFILESDIR=share/mysql"
74 "-DINSTALL_MYSQLSHAREDIR=share/mysql"
75 "-DINSTALL_MYSQLTESTDIR="
76 "-DINSTALL_DOCDIR=share/mysql/docs"
77 "-DINSTALL_SHAREDIR=share/mysql"
80 ] ++ lib.optionals stdenv.isLinux [
82 "-DWITH_SYSTEMD_DEBUG=1"
84 ++ lib.optional (stdenv.isLinux && withJemalloc) "-DWITH_JEMALLOC=1"
85 ++ lib.optional (stdenv.isLinux && withTcmalloc) "-DWITH_TCMALLOC=1";
88 moveToOutput "lib/*.a" $static
89 so=${stdenv.hostPlatform.extensions.sharedLibrary}
90 ln -s libmysqlclient$so $out/lib/libmysqlclient_r$so
94 client = finalAttrs.finalPackage;
95 connector-c = finalAttrs.finalPackage;
96 server = finalAttrs.finalPackage;
97 mysqlVersion = lib.versions.majorMinor finalAttrs.version;
98 tests = nixosTests.mysql.percona-server_innovation;
103 homepage = "https://www.percona.com/software/mysql-database/percona-server";
105 A free, fully compatible, enhanced, open source drop-in replacement for
106 MySQL® that provides superior performance, scalability and instrumentation.
108 license = licenses.gpl2;
109 maintainers = teams.flyingcircus.members;
110 platforms = platforms.unix;