nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 gitUpdater,
7 bison,
8 cmake,
9 pkg-config,
10 boost,
11 icu,
12 libedit,
13 libevent,
14 lz4,
15 ncurses,
16 openssl,
17 perl,
18 protobuf,
19 re2,
20 readline,
21 zlib,
22 zstd,
23 libfido2,
24 numactl,
25 cctools,
26 developer_cmds,
27 libtirpc,
28 rpcsvc-proto,
29 curl,
30 DarwinTools,
31 nixosTests,
32 coreutils,
33 procps,
34 gnused,
35 gnugrep,
36 hostname,
37 makeWrapper,
38 # Percona-specific deps
39 cyrus_sasl,
40 gnumake,
41 openldap,
42}:
43
44stdenv.mkDerivation (finalAttrs: {
45 pname = "percona-server";
46 version = "8.0.44-35";
47
48 src = fetchurl {
49 url = "https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-${finalAttrs.version}/source/tarball/percona-server-${finalAttrs.version}.tar.gz";
50 hash = "sha256-4eiNKzXzc5TAhsdIKQvyhQknsOiVSSkbZXDFY+qInYE=";
51 };
52
53 nativeBuildInputs = [
54 bison
55 cmake
56 pkg-config
57 makeWrapper
58 # required for scripts/CMakeLists.txt
59 coreutils
60 gnugrep
61 procps
62 ]
63 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ];
64
65 patches = [
66 # fixes using -DWITH_SSL=system with CMAKE_PREFIX_PATH on darwin
67 # https://github.com/Homebrew/homebrew-core/pull/204799
68 (fetchpatch {
69 name = "fix-system-ssl-darwin.patch";
70 url = "https://github.com/percona/percona-server/pull/5537/commits/a693e5d67abf6f27f5284c86361604babec529c6.patch";
71 hash = "sha256-fFBy3AYTMLvHvbsh0g0UvuPkmVMKZzxPsxeBKbsN8Ho=";
72 })
73 ./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch
74 ./coredumper-explicitly-import-unistd.patch # fix build on aarch64-linux
75 ];
76
77 ## NOTE: MySQL upstream frequently twiddles the invocations of libtool. When updating, you might proactively grep for libtool references.
78 postPatch = ''
79 substituteInPlace cmake/libutils.cmake --replace /usr/bin/libtool libtool
80 substituteInPlace cmake/os/Darwin.cmake --replace /usr/bin/libtool libtool
81 # The rocksdb setup script is called with `env -i` and cannot find anything in PATH.
82 patchShebangs storage/rocksdb/get_rocksdb_files.sh
83 substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace mktemp ${coreutils}/bin/mktemp
84 substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "rm $MKFILE" "${coreutils}/bin/rm $MKFILE"
85 substituteInPlace storage/rocksdb/get_rocksdb_files.sh --replace "make --" "${gnumake}/bin/make --"
86 '';
87
88 buildInputs = [
89 boost
90 (curl.override { inherit openssl; })
91 icu
92 libedit
93 libevent
94 lz4
95 ncurses
96 openssl
97 protobuf
98 re2
99 readline
100 zlib
101 zstd
102 libfido2
103 openldap
104 perl
105 cyrus_sasl
106 ]
107 ++ lib.optionals stdenv.hostPlatform.isLinux [
108 numactl
109 libtirpc
110 ]
111 ++ lib.optionals stdenv.hostPlatform.isDarwin [
112 cctools
113 developer_cmds
114 DarwinTools
115 ];
116
117 outputs = [
118 "out"
119 "static"
120 ];
121
122 cmakeFlags = [
123 # Percona-specific flags.
124 "-DPORTABLE=1"
125 "-DWITH_LDAP=system"
126 "-DROCKSDB_DISABLE_AVX2=1"
127 "-DROCKSDB_DISABLE_MARCH_NATIVE=1"
128
129 # Flags taken from mysql package.
130 "-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin.
131 "-DWITH_ROUTER=OFF" # It may be packaged separately.
132 "-DWITH_SYSTEM_LIBS=ON"
133 "-DWITH_UNIT_TESTS=OFF"
134 "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock"
135 "-DMYSQL_DATADIR=/var/lib/mysql"
136 "-DINSTALL_INFODIR=share/mysql/docs"
137 "-DINSTALL_MANDIR=share/man"
138 "-DINSTALL_PLUGINDIR=lib/mysql/plugin"
139 "-DINSTALL_INCLUDEDIR=include/mysql"
140 "-DINSTALL_DOCREADMEDIR=share/mysql"
141 "-DINSTALL_SUPPORTFILESDIR=share/mysql"
142 "-DINSTALL_MYSQLSHAREDIR=share/mysql"
143 "-DINSTALL_MYSQLTESTDIR="
144 "-DINSTALL_DOCDIR=share/mysql/docs"
145 "-DINSTALL_SHAREDIR=share/mysql"
146 ];
147
148 postInstall = ''
149 moveToOutput "lib/*.a" $static
150 so=${stdenv.hostPlatform.extensions.sharedLibrary}
151 ln -s libperconaserverclient$so $out/lib/libmysqlclient_r$so
152
153 wrapProgram $out/bin/mysqld_safe --prefix PATH : ${
154 lib.makeBinPath [
155 coreutils
156 procps
157 gnugrep
158 gnused
159 hostname
160 ]
161 }
162 wrapProgram $out/bin/mysql_config --prefix PATH : ${
163 lib.makeBinPath [
164 coreutils
165 gnused
166 ]
167 }
168 wrapProgram $out/bin/ps_mysqld_helper --prefix PATH : ${
169 lib.makeBinPath [
170 coreutils
171 gnugrep
172 ]
173 }
174 wrapProgram $out/bin/ps-admin --prefix PATH : ${
175 lib.makeBinPath [
176 coreutils
177 gnugrep
178 ]
179 }
180 wrapProgram $out/bin/mysqld_multi --prefix PATH : ${
181 lib.makeBinPath [
182 coreutils
183 gnugrep
184 ]
185 }
186 '';
187
188 passthru = {
189 client = finalAttrs.finalPackage;
190 connector-c = finalAttrs.finalPackage;
191 server = finalAttrs.finalPackage;
192 mysqlVersion = lib.versions.majorMinor finalAttrs.version;
193 tests.percona-server =
194 nixosTests.mysql."percona-server_${lib.versions.major finalAttrs.version}_${lib.versions.minor finalAttrs.version}";
195 updateScript = gitUpdater {
196 url = "https://github.com/percona/percona-server";
197 rev-prefix = "Percona-Server-";
198 allowedVersions = "${lib.versions.major finalAttrs.version}\\.${lib.versions.minor finalAttrs.version}\\..+";
199 };
200 };
201
202 meta = {
203 homepage = "https://www.percona.com/software/mysql-database/percona-server";
204 description = ''
205 A free, fully compatible, enhanced, open source drop-in replacement for
206 MySQL® that provides superior performance, scalability and instrumentation.
207 Long-term support release.
208 '';
209 license = lib.licenses.gpl2Only;
210 maintainers = [
211 lib.maintainers.leona
212 lib.maintainers.osnyx
213 ];
214 platforms = lib.platforms.unix;
215 };
216})