Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 225 lines 5.9 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 gitUpdater, 6 bison, 7 cmake, 8 pkg-config, 9 boost, 10 icu, 11 libedit, 12 libevent, 13 lz4, 14 ncurses, 15 openssl, 16 perl, 17 protobuf, 18 re2, 19 readline, 20 zlib, 21 zstd, 22 libfido2, 23 numactl, 24 cctools, 25 developer_cmds, 26 libtirpc, 27 rpcsvc-proto, 28 curl, 29 DarwinTools, 30 nixosTests, 31 coreutils, 32 procps, 33 gnused, 34 gnugrep, 35 hostname, 36 makeWrapper, 37 systemd, 38 # Percona-specific deps 39 cyrus_sasl, 40 gnumake, 41 openldap, 42 # optional: different malloc implementations 43 withJemalloc ? false, 44 withTcmalloc ? false, 45 jemalloc, 46 gperftools, 47}: 48 49assert !(withJemalloc && withTcmalloc); 50 51stdenv.mkDerivation (finalAttrs: { 52 pname = "percona-server"; 53 version = "8.4.5-5"; 54 55 src = fetchurl { 56 url = "https://downloads.percona.com/downloads/Percona-Server-${lib.versions.majorMinor finalAttrs.version}/Percona-Server-${finalAttrs.version}/source/tarball/percona-server-${finalAttrs.version}.tar.gz"; 57 hash = "sha256-i0f/Ndwqbn6qyqLSBK5FbBW12ZUzYMy2JQ2o1o2Y9q8="; 58 }; 59 60 nativeBuildInputs = [ 61 bison 62 cmake 63 pkg-config 64 makeWrapper 65 # required for scripts/CMakeLists.txt 66 coreutils 67 gnugrep 68 procps 69 ] 70 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ]; 71 72 patches = [ 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 systemd 111 ] 112 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 113 cctools 114 developer_cmds 115 DarwinTools 116 ] 117 ++ lib.optional (stdenv.hostPlatform.isLinux && withJemalloc) jemalloc 118 ++ lib.optional (stdenv.hostPlatform.isLinux && withTcmalloc) gperftools; 119 120 outputs = [ 121 "out" 122 "static" 123 ]; 124 125 cmakeFlags = [ 126 # Percona-specific flags. 127 "-DPORTABLE=1" 128 "-DWITH_LDAP=system" 129 "-DROCKSDB_DISABLE_AVX2=1" 130 "-DROCKSDB_DISABLE_MARCH_NATIVE=1" 131 132 # Flags taken from mysql package. 133 "-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin. 134 "-DWITH_ROUTER=OFF" # It may be packaged separately. 135 "-DWITH_SYSTEM_LIBS=ON" 136 "-DWITH_UNIT_TESTS=OFF" 137 "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock" 138 "-DMYSQL_DATADIR=/var/lib/mysql" 139 "-DINSTALL_INFODIR=share/mysql/docs" 140 "-DINSTALL_MANDIR=share/man" 141 "-DINSTALL_PLUGINDIR=lib/mysql/plugin" 142 "-DINSTALL_INCLUDEDIR=include/mysql" 143 "-DINSTALL_DOCREADMEDIR=share/mysql" 144 "-DINSTALL_SUPPORTFILESDIR=share/mysql" 145 "-DINSTALL_MYSQLSHAREDIR=share/mysql" 146 "-DINSTALL_MYSQLTESTDIR=" 147 "-DINSTALL_DOCDIR=share/mysql/docs" 148 "-DINSTALL_SHAREDIR=share/mysql" 149 150 ] 151 ++ lib.optionals stdenv.hostPlatform.isLinux [ 152 "-DWITH_SYSTEMD=1" 153 "-DWITH_SYSTEMD_DEBUG=1" 154 ] 155 ++ lib.optional (stdenv.hostPlatform.isLinux && withJemalloc) "-DWITH_JEMALLOC=1" 156 ++ lib.optional (stdenv.hostPlatform.isLinux && withTcmalloc) "-DWITH_TCMALLOC=1"; 157 158 postInstall = '' 159 moveToOutput "lib/*.a" $static 160 so=${stdenv.hostPlatform.extensions.sharedLibrary} 161 ln -s libperconaserverclient$so $out/lib/libmysqlclient_r$so 162 163 wrapProgram $out/bin/mysqld_safe --prefix PATH : ${ 164 lib.makeBinPath [ 165 coreutils 166 procps 167 gnugrep 168 gnused 169 hostname 170 ] 171 } 172 wrapProgram $out/bin/mysql_config --prefix PATH : ${ 173 lib.makeBinPath [ 174 coreutils 175 gnused 176 ] 177 } 178 wrapProgram $out/bin/ps_mysqld_helper --prefix PATH : ${ 179 lib.makeBinPath [ 180 coreutils 181 gnugrep 182 ] 183 } 184 wrapProgram $out/bin/ps-admin --prefix PATH : ${ 185 lib.makeBinPath [ 186 coreutils 187 gnugrep 188 ] 189 } 190 '' 191 + lib.optionalString stdenv.hostPlatform.isDarwin '' 192 wrapProgram $out/bin/mysqld_multi --prefix PATH : ${ 193 lib.makeBinPath [ 194 coreutils 195 gnugrep 196 ] 197 } 198 ''; 199 200 passthru = { 201 client = finalAttrs.finalPackage; 202 connector-c = finalAttrs.finalPackage; 203 server = finalAttrs.finalPackage; 204 mysqlVersion = lib.versions.majorMinor finalAttrs.version; 205 tests.percona-server = 206 nixosTests.mysql."percona-server_${lib.versions.major finalAttrs.version}_${lib.versions.minor finalAttrs.version}"; 207 updateScript = gitUpdater { 208 url = "https://github.com/percona/percona-server"; 209 rev-prefix = "Percona-Server-"; 210 allowedVersions = "${lib.versions.major finalAttrs.version}\\.${lib.versions.minor finalAttrs.version}\\..+"; 211 }; 212 }; 213 214 meta = with lib; { 215 homepage = "https://www.percona.com/software/mysql-database/percona-server"; 216 description = '' 217 A free, fully compatible, enhanced, open source drop-in replacement for 218 MySQL® that provides superior performance, scalability and instrumentation. 219 Long-term support release. 220 ''; 221 license = licenses.gpl2Only; 222 teams = [ teams.flyingcircus ]; 223 platforms = platforms.unix; 224 }; 225})