Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at github-to-sqlite-beautifulsoup4 281 lines 11 kB view raw
1let 2 # shared across all versions 3 generic = 4 { version, hash 5 , lib, stdenv, fetchurl, nixosTests, buildPackages 6 # Native buildInputs components 7 , bison, boost, cmake, fixDarwinDylibNames, flex, makeWrapper, pkg-config 8 # Common components 9 , curl, libiconv, ncurses, openssl, pcre2 10 , libkrb5, libaio, liburing, systemd 11 , CoreServices, cctools, perl 12 , jemalloc, less, libedit 13 # Server components 14 , bzip2, lz4, lzo, snappy, xz, zlib, zstd 15 , cracklib, judy, libevent, libxml2 16 , linux-pam, numactl 17 , fmt_8 18 , withStorageMroonga ? true, kytea, libsodium, msgpack, zeromq 19 , withStorageRocks ? true 20 , withEmbedded ? false 21 , withNuma ? false 22 }: 23 24 let 25 isCross = stdenv.buildPlatform != stdenv.hostPlatform; 26 27 libExt = stdenv.hostPlatform.extensions.sharedLibrary; 28 29 mytopEnv = buildPackages.perl.withPackages (p: with p; [ DBDmysql DBI TermReadKey ]); 30 31 common = rec { # attributes common to both builds 32 inherit version; 33 34 src = fetchurl { 35 url = "https://downloads.mariadb.com/MariaDB/mariadb-${version}/source/mariadb-${version}.tar.gz"; 36 inherit hash; 37 }; 38 39 outputs = [ "out" "man" ]; 40 41 nativeBuildInputs = [ cmake pkg-config ] 42 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames 43 ++ lib.optional (!stdenv.hostPlatform.isDarwin) makeWrapper; 44 45 buildInputs = [ 46 libiconv ncurses zlib 47 pcre2 48 openssl 49 curl 50 ] ++ lib.optionals stdenv.hostPlatform.isLinux ([ libkrb5 systemd ] 51 ++ (if (lib.versionOlder version "10.6") then [ libaio ] else [ liburing ])) 52 ++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices cctools perl libedit ] 53 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ jemalloc ]; 54 55 prePatch = '' 56 sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt 57 ''; 58 59 patches = [ 60 ./patch/cmake-includedir.patch 61 ] 62 # Fixes a build issue as documented on 63 # https://jira.mariadb.org/browse/MDEV-26769?focusedCommentId=206073&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-206073 64 ++ lib.optional (!stdenv.hostPlatform.isLinux && lib.versionAtLeast version "10.6") ./patch/macos-MDEV-26769-regression-fix.patch; 65 66 cmakeFlags = [ 67 "-DBUILD_CONFIG=mysql_release" 68 "-DMANUFACTURER=nixos.org" 69 "-DDEFAULT_CHARSET=utf8mb4" 70 "-DDEFAULT_COLLATION=utf8mb4_unicode_ci" 71 "-DSECURITY_HARDENED=ON" 72 73 "-DINSTALL_UNIX_ADDRDIR=/run/mysqld/mysqld.sock" 74 "-DINSTALL_BINDIR=bin" 75 "-DINSTALL_DOCDIR=share/doc/mysql" 76 "-DINSTALL_DOCREADMEDIR=share/doc/mysql" 77 "-DINSTALL_INCLUDEDIR=include/mysql" 78 "-DINSTALL_LIBDIR=lib" 79 "-DINSTALL_PLUGINDIR=lib/mysql/plugin" 80 "-DINSTALL_INFODIR=share/mysql/docs" 81 "-DINSTALL_MANDIR=share/man" 82 "-DINSTALL_MYSQLSHAREDIR=share/mysql" 83 "-DINSTALL_SCRIPTDIR=bin" 84 "-DINSTALL_SUPPORTFILESDIR=share/doc/mysql" 85 "-DINSTALL_MYSQLTESTDIR=OFF" 86 "-DINSTALL_SQLBENCHDIR=OFF" 87 "-DINSTALL_PAMDIR=share/pam/lib/security" 88 "-DINSTALL_PAMDATADIR=share/pam/etc/security" 89 90 "-DWITH_ZLIB=system" 91 "-DWITH_SSL=system" 92 "-DWITH_PCRE=system" 93 "-DWITH_SAFEMALLOC=OFF" 94 "-DWITH_UNIT_TESTS=OFF" 95 "-DEMBEDDED_LIBRARY=OFF" 96 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ 97 # On Darwin without sandbox, CMake will find the system java and attempt to build with java support, but 98 # then it will fail during the actual build. Let's just disable the flag explicitly until someone decides 99 # to pass in java explicitly. 100 "-DCONNECT_WITH_JDBC=OFF" 101 "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib" 102 ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "10.6") [ 103 # workaround for https://jira.mariadb.org/browse/MDEV-29925 104 "-Dhave_C__Wl___as_needed=" 105 ] ++ lib.optionals isCross [ 106 # revisit this if nixpkgs supports any architecture whose stack grows upwards 107 "-DSTACK_DIRECTION=-1" 108 "-DCMAKE_CROSSCOMPILING_EMULATOR=${stdenv.hostPlatform.emulator buildPackages}" 109 ]; 110 111 postInstall = lib.optionalString (!withEmbedded) '' 112 # Remove Development components. Need to use libmysqlclient. 113 rm "$out"/lib/mysql/plugin/daemon_example.ini 114 rm "$out"/lib/{libmariadb.a,libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a} 115 rm -f "$out"/bin/{mariadb-config,mariadb_config,mysql_config} 116 rm -r $out/include 117 rm -r $out/lib/pkgconfig 118 ''; 119 120 # perlPackages.DBDmysql is broken on darwin 121 postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 122 wrapProgram $out/bin/mytop --set PATH ${lib.makeBinPath [ less ncurses ]} 123 ''; 124 125 passthru.tests = let 126 testVersion = "mariadb_${builtins.replaceStrings ["."] [""] (lib.versions.majorMinor version)}"; 127 in { 128 mariadb-galera-rsync = nixosTests.mariadb-galera.${testVersion}; 129 mysql = nixosTests.mysql.${testVersion}; 130 mysql-autobackup = nixosTests.mysql-autobackup.${testVersion}; 131 mysql-backup = nixosTests.mysql-backup.${testVersion}; 132 mysql-replication = nixosTests.mysql-replication.${testVersion}; 133 }; 134 135 meta = with lib; { 136 description = "An enhanced, drop-in replacement for MySQL"; 137 homepage = "https://mariadb.org/"; 138 license = licenses.gpl2; 139 maintainers = with maintainers; [ thoughtpolice ajs124 das_j ]; 140 platforms = platforms.all; 141 }; 142 }; 143 144 client = stdenv.mkDerivation (common // { 145 pname = "mariadb-client"; 146 147 patches = common.patches ++ [ 148 ./patch/cmake-plugin-includedir.patch 149 ]; 150 151 buildInputs = common.buildInputs 152 ++ lib.optionals (lib.versionAtLeast common.version "10.7") [ fmt_8 ]; 153 154 cmakeFlags = common.cmakeFlags ++ [ 155 "-DPLUGIN_AUTH_PAM=NO" 156 "-DWITHOUT_SERVER=ON" 157 "-DWITH_WSREP=OFF" 158 "-DINSTALL_MYSQLSHAREDIR=share/mysql-client" 159 ]; 160 161 postInstall = common.postInstall + '' 162 rm "$out"/bin/{mariadb-test,mysqltest} 163 libmysqlclient_path=$(readlink -f $out/lib/libmysqlclient${libExt}) 164 rm "$out"/lib/{libmariadb${libExt},libmysqlclient${libExt},libmysqlclient_r${libExt}} 165 mv "$libmysqlclient_path" "$out"/lib/libmysqlclient${libExt} 166 ln -sv libmysqlclient${libExt} "$out"/lib/libmysqlclient_r${libExt} 167 ''; 168 }); 169 170 server = stdenv.mkDerivation (common // { 171 pname = "mariadb-server"; 172 173 nativeBuildInputs = common.nativeBuildInputs ++ [ bison boost.dev flex ]; 174 175 buildInputs = common.buildInputs ++ [ 176 bzip2 lz4 lzo snappy xz zstd 177 cracklib judy libevent libxml2 178 ] ++ lib.optional withNuma numactl 179 ++ lib.optionals stdenv.hostPlatform.isLinux [ linux-pam ] 180 ++ lib.optional (!stdenv.hostPlatform.isDarwin) mytopEnv 181 ++ lib.optionals withStorageMroonga [ kytea libsodium msgpack zeromq ] 182 ++ lib.optionals (lib.versionAtLeast common.version "10.7") [ fmt_8 ]; 183 184 propagatedBuildInputs = lib.optional withNuma numactl; 185 186 postPatch = '' 187 substituteInPlace scripts/galera_new_cluster.sh \ 188 --replace ":-mariadb" ":-mysql" 189 ''; 190 191 cmakeFlags = common.cmakeFlags ++ [ 192 "-DMYSQL_DATADIR=/var/lib/mysql" 193 "-DENABLED_LOCAL_INFILE=OFF" 194 "-DWITH_READLINE=ON" 195 "-DWITH_EXTRA_CHARSETS=all" 196 "-DWITH_EMBEDDED_SERVER=${if withEmbedded then "ON" else "OFF"}" 197 "-DWITH_UNIT_TESTS=OFF" 198 "-DWITH_WSREP=ON" 199 "-DWITH_INNODB_DISALLOW_WRITES=ON" 200 "-DWITHOUT_EXAMPLE=1" 201 "-DWITHOUT_FEDERATED=1" 202 "-DWITHOUT_TOKUDB=1" 203 ] ++ lib.optionals withNuma [ 204 "-DWITH_NUMA=ON" 205 ] ++ lib.optionals (!withStorageMroonga) [ 206 "-DWITHOUT_MROONGA=1" 207 ] ++ lib.optionals (!withStorageRocks) [ 208 "-DWITHOUT_ROCKSDB=1" 209 ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin && withStorageRocks) [ 210 "-DWITH_ROCKSDB_JEMALLOC=ON" 211 ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ 212 "-DWITH_JEMALLOC=yes" 213 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ 214 "-DPLUGIN_AUTH_PAM=NO" 215 "-DPLUGIN_AUTH_PAM_V1=NO" 216 "-DWITHOUT_OQGRAPH=1" 217 "-DWITHOUT_PLUGIN_S3=1" 218 ]; 219 220 preConfigure = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 221 patchShebangs scripts/mytop.sh 222 ''; 223 224 postInstall = common.postInstall + '' 225 rm -r "$out"/share/aclocal 226 chmod +x "$out"/bin/wsrep_sst_common 227 rm -f "$out"/bin/{mariadb-client-test,mariadb-test,mysql_client_test,mysqltest} 228 '' + lib.optionalString withStorageMroonga '' 229 mv "$out"/share/{groonga,groonga-normalizer-mysql} "$out"/share/doc/mysql 230 '' + lib.optionalString (!stdenv.hostPlatform.isDarwin && lib.versionAtLeast common.version "10.4") '' 231 mv "$out"/OFF/suite/plugins/pam/pam_mariadb_mtr.so "$out"/share/pam/lib/security 232 mv "$out"/OFF/suite/plugins/pam/mariadb_mtr "$out"/share/pam/etc/security 233 rm -r "$out"/OFF 234 ''; 235 236 CXXFLAGS = lib.optionalString stdenv.hostPlatform.isi686 "-fpermissive"; 237 NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic"; 238 }); 239 in 240 server // { 241 inherit client server; 242 }; 243in 244 self: { 245 # see https://mariadb.org/about/#maintenance-policy for EOLs 246 mariadb_105 = self.callPackage generic { 247 # Supported until 2025-06-24 248 version = "10.5.22"; 249 hash = "sha256-PiOGu17iWo3c0hz/xIx2CX5cpBpuSgmPay7kASsNY44="; 250 inherit (self.darwin) cctools; 251 inherit (self.darwin.apple_sdk.frameworks) CoreServices; 252 }; 253 mariadb_106 = self.callPackage generic { 254 # Supported until 2026-07-06 255 version = "10.6.15"; 256 hash = "sha256-sva9uhfq1NkcTSVPr8NKcorGsCfdHXF4vCZ1jc5pQzU="; 257 inherit (self.darwin) cctools; 258 inherit (self.darwin.apple_sdk.frameworks) CoreServices; 259 }; 260 mariadb_1010 = self.callPackage generic { 261 # Supported until 2023-11-17. TODO: remove ahead of 23.11 branchoff 262 version = "10.10.6"; 263 hash = "sha256-4eUwEZedKfDsJuE6uMr2E0gb8ClSBWb7loF1RhA5ONU="; 264 inherit (self.darwin) cctools; 265 inherit (self.darwin.apple_sdk.frameworks) CoreServices; 266 }; 267 mariadb_1011 = self.callPackage generic { 268 # Supported until 2028-02-16 269 version = "10.11.5"; 270 hash = "sha256-TJSEBI1NDHHdB2qzP8KpzoUQvfdiiG3g1j/lJJbz27s="; 271 inherit (self.darwin) cctools; 272 inherit (self.darwin.apple_sdk.frameworks) CoreServices; 273 }; 274 mariadb_110 = self.callPackage generic { 275 # Supported until 2024-06-07 276 version = "11.0.3"; 277 hash = "sha256-Up8IoGTudzOhNuxHSkI56Kyb1tsTm4unC/+KfxMDg5o="; 278 inherit (self.darwin) cctools; 279 inherit (self.darwin.apple_sdk.frameworks) CoreServices; 280 }; 281 }