nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 399 lines 12 kB view raw
1let 2 # shared across all versions 3 generic = 4 { 5 version, 6 hash, 7 lib, 8 stdenv, 9 fetchurl, 10 nixosTests, 11 buildPackages, 12 # Native buildInputs components 13 bison, 14 boost, 15 cmake, 16 fixDarwinDylibNames, 17 flex, 18 makeWrapper, 19 pkg-config, 20 # Common components 21 curl, 22 libiconv, 23 ncurses, 24 openssl, 25 pcre2, 26 libkrb5, 27 libaio, 28 liburing, 29 systemd, 30 cctools, 31 perl, 32 jemalloc, 33 less, 34 libedit, 35 # Server components 36 bzip2, 37 lz4, 38 lzo, 39 snappy, 40 xz, 41 zlib, 42 zstd, 43 cracklib, 44 judy, 45 libevent, 46 libxml2, 47 linux-pam, 48 numactl, 49 fmt, 50 withStorageMroonga ? true, 51 kytea, 52 libsodium, 53 msgpack-cxx, 54 zeromq, 55 withStorageRocks ? true, 56 withEmbedded ? false, 57 withNuma ? false, 58 }: 59 60 let 61 isCross = stdenv.buildPlatform != stdenv.hostPlatform; 62 63 libExt = stdenv.hostPlatform.extensions.sharedLibrary; 64 65 mytopEnv = buildPackages.perl.withPackages ( 66 p: with p; [ 67 DBDMariaDB 68 DBI 69 TermReadKey 70 ] 71 ); 72 73 common = rec { 74 # attributes common to both builds 75 inherit version; 76 77 src = fetchurl { 78 url = "https://archive.mariadb.org/mariadb-${version}/source/mariadb-${version}.tar.gz"; 79 inherit hash; 80 }; 81 82 outputs = [ 83 "out" 84 "man" 85 ]; 86 87 nativeBuildInputs = [ 88 cmake 89 pkg-config 90 ] 91 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames 92 ++ lib.optional (!stdenv.hostPlatform.isDarwin) makeWrapper; 93 94 buildInputs = [ 95 libiconv 96 ncurses 97 zlib 98 pcre2 99 openssl 100 curl 101 ] 102 ++ lib.optionals stdenv.hostPlatform.isLinux ( 103 [ 104 libkrb5 105 systemd 106 ] 107 ++ (if (lib.versionOlder version "10.6") then [ libaio ] else [ liburing ]) 108 ) 109 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 110 cctools 111 perl 112 libedit 113 ] 114 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ jemalloc ]; 115 116 prePatch = '' 117 sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt 118 ''; 119 env = 120 lib.optionalAttrs (stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isGnu) { 121 # MariaDB uses non-POSIX fopen64, which musl only conditionally defines. 122 NIX_CFLAGS_COMPILE = "-D_LARGEFILE64_SOURCE"; 123 } 124 // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) { 125 # Detection of netdb.h doesnt work for some reason on x86_64-darwin 126 NIX_CFLAGS_COMPILE = "-DHAVE_NETDB_H"; 127 }; 128 129 patches = [ 130 ./patch/cmake-includedir.patch 131 # patch for musl compatibility 132 ./patch/include-cstdint-full.patch 133 ] 134 # Fixes a build issue as documented on 135 # https://jira.mariadb.org/browse/MDEV-26769?focusedCommentId=206073&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-206073 136 ++ lib.optional ( 137 !stdenv.hostPlatform.isLinux && lib.versionAtLeast version "10.6" 138 ) ./patch/macos-MDEV-26769-regression-fix.patch; 139 140 cmakeFlags = [ 141 "-DBUILD_CONFIG=mysql_release" 142 "-DMANUFACTURER=nixos.org" 143 "-DDEFAULT_CHARSET=utf8mb4" 144 "-DDEFAULT_COLLATION=utf8mb4_unicode_ci" 145 "-DSECURITY_HARDENED=ON" 146 147 "-DINSTALL_UNIX_ADDRDIR=/run/mysqld/mysqld.sock" 148 "-DINSTALL_BINDIR=bin" 149 "-DINSTALL_DOCDIR=share/doc/mysql" 150 "-DINSTALL_DOCREADMEDIR=share/doc/mysql" 151 "-DINSTALL_INCLUDEDIR=include/mysql" 152 "-DINSTALL_LIBDIR=lib" 153 "-DINSTALL_PLUGINDIR=lib/mysql/plugin" 154 "-DINSTALL_INFODIR=share/mysql/docs" 155 "-DINSTALL_MANDIR=share/man" 156 "-DINSTALL_MYSQLSHAREDIR=share/mysql" 157 "-DINSTALL_SCRIPTDIR=bin" 158 "-DINSTALL_SUPPORTFILESDIR=share/doc/mysql" 159 "-DINSTALL_MYSQLTESTDIR=OFF" 160 "-DINSTALL_SQLBENCHDIR=OFF" 161 "-DINSTALL_PAMDIR=share/pam/lib/security" 162 "-DINSTALL_PAMDATADIR=share/pam/etc/security" 163 164 "-DWITH_ZLIB=system" 165 "-DWITH_SSL=system" 166 "-DWITH_PCRE=system" 167 "-DWITH_SAFEMALLOC=OFF" 168 "-DWITH_UNIT_TESTS=OFF" 169 "-DEMBEDDED_LIBRARY=OFF" 170 ] 171 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 172 # On Darwin without sandbox, CMake will find the system java and attempt to build with java support, but 173 # then it will fail during the actual build. Let's just disable the flag explicitly until someone decides 174 # to pass in java explicitly. 175 "-DCONNECT_WITH_JDBC=OFF" 176 "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib" 177 ] 178 ++ lib.optionals (stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "10.6") [ 179 # workaround for https://jira.mariadb.org/browse/MDEV-29925 180 "-Dhave_C__Wl___as_needed=" 181 ] 182 ++ lib.optionals isCross [ 183 # revisit this if nixpkgs supports any architecture whose stack grows upwards 184 "-DSTACK_DIRECTION=-1" 185 "-DCMAKE_CROSSCOMPILING_EMULATOR=${stdenv.hostPlatform.emulator buildPackages}" 186 ]; 187 188 postInstall = lib.optionalString (!withEmbedded) '' 189 # Remove Development components. Need to use libmysqlclient. 190 rm "$out"/lib/mysql/plugin/daemon_example.ini 191 rm "$out"/lib/{libmariadb.a,libmariadbclient.a,libmysqlclient.a,libmysqlclient_r.a,libmysqlservices.a} 192 rm -f "$out"/bin/{mariadb-config,mariadb_config,mysql_config} 193 rm -r $out/include 194 rm -r $out/lib/pkgconfig 195 ''; 196 197 # perlPackages.DBDmysql is broken on darwin 198 postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 199 wrapProgram $out/bin/mytop --set PATH ${ 200 lib.makeBinPath [ 201 less 202 ncurses 203 ] 204 } 205 ''; 206 207 passthru.tests = 208 let 209 testVersion = "mariadb_${builtins.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor version)}"; 210 in 211 { 212 mariadb-galera-rsync = nixosTests.mariadb-galera.${testVersion}; 213 mysql = nixosTests.mysql.${testVersion}; 214 mysql-autobackup = nixosTests.mysql-autobackup.${testVersion}; 215 mysql-backup = nixosTests.mysql-backup.${testVersion}; 216 mysql-replication = nixosTests.mysql-replication.${testVersion}; 217 }; 218 219 meta = { 220 description = "Enhanced, drop-in replacement for MySQL"; 221 homepage = "https://mariadb.org/"; 222 license = lib.licenses.gpl2Plus; 223 maintainers = with lib.maintainers; [ 224 conni2461 225 das_j 226 helsinki-Jo 227 thoughtpolice 228 ]; 229 platforms = lib.platforms.all; 230 }; 231 }; 232 233 client = stdenv.mkDerivation ( 234 common 235 // { 236 pname = "mariadb-client"; 237 238 patches = common.patches ++ [ 239 ./patch/cmake-plugin-includedir.patch 240 ]; 241 242 buildInputs = 243 common.buildInputs ++ lib.optionals (lib.versionAtLeast common.version "10.11") [ fmt ]; 244 245 cmakeFlags = common.cmakeFlags ++ [ 246 "-DPLUGIN_AUTH_PAM=NO" 247 "-DWITHOUT_SERVER=ON" 248 "-DWITH_WSREP=OFF" 249 "-DINSTALL_MYSQLSHAREDIR=share/mysql-client" 250 ]; 251 252 postInstall = common.postInstall + '' 253 rm "$out"/bin/{mariadb-test,mysqltest} 254 libmysqlclient_path=$(readlink -f $out/lib/libmysqlclient${libExt}) 255 rm "$out"/lib/{libmariadb${libExt},libmysqlclient${libExt},libmysqlclient_r${libExt}} 256 mv "$libmysqlclient_path" "$out"/lib/libmysqlclient${libExt} 257 ln -sv libmysqlclient${libExt} "$out"/lib/libmysqlclient_r${libExt} 258 ''; 259 } 260 ); 261 in 262 263 stdenv.mkDerivation ( 264 finalAttrs: 265 common 266 // { 267 pname = "mariadb-server"; 268 269 nativeBuildInputs = common.nativeBuildInputs ++ [ 270 bison 271 boost.dev 272 flex 273 ]; 274 275 buildInputs = 276 common.buildInputs 277 ++ [ 278 bzip2 279 lz4 280 lzo 281 snappy 282 xz 283 zstd 284 cracklib 285 judy 286 libevent 287 libxml2 288 ] 289 ++ lib.optional withNuma numactl 290 ++ lib.optionals stdenv.hostPlatform.isLinux [ linux-pam ] 291 ++ lib.optional (!stdenv.hostPlatform.isDarwin) mytopEnv 292 ++ lib.optionals withStorageMroonga [ 293 kytea 294 libsodium 295 msgpack-cxx 296 zeromq 297 ] 298 ++ lib.optionals (lib.versionAtLeast common.version "10.11") [ fmt ]; 299 300 propagatedBuildInputs = lib.optional withNuma numactl; 301 302 postPatch = '' 303 substituteInPlace scripts/galera_new_cluster.sh \ 304 --replace ":-mariadb" ":-mysql" 305 ''; 306 307 cmakeFlags = 308 common.cmakeFlags 309 ++ [ 310 "-DMYSQL_DATADIR=/var/lib/mysql" 311 "-DENABLED_LOCAL_INFILE=OFF" 312 "-DWITH_READLINE=ON" 313 "-DWITH_EXTRA_CHARSETS=all" 314 "-DWITH_EMBEDDED_SERVER=${if withEmbedded then "ON" else "OFF"}" 315 "-DWITH_UNIT_TESTS=OFF" 316 "-DWITH_WSREP=ON" 317 "-DWITH_INNODB_DISALLOW_WRITES=ON" 318 "-DWITHOUT_EXAMPLE=1" 319 "-DWITHOUT_FEDERATED=1" 320 "-DWITHOUT_TOKUDB=1" 321 ] 322 ++ lib.optionals (lib.versionOlder version "11.4") [ 323 # Fix the build with CMake 4. 324 "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" 325 ] 326 ++ lib.optionals withNuma [ 327 "-DWITH_NUMA=ON" 328 ] 329 ++ lib.optionals (!withStorageMroonga) [ 330 "-DWITHOUT_MROONGA=1" 331 ] 332 ++ lib.optionals (!withStorageRocks) [ 333 "-DWITHOUT_ROCKSDB=1" 334 ] 335 ++ lib.optionals (!stdenv.hostPlatform.isDarwin && withStorageRocks) [ 336 "-DWITH_ROCKSDB_JEMALLOC=ON" 337 ] 338 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ 339 "-DWITH_JEMALLOC=yes" 340 ] 341 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 342 "-DPLUGIN_AUTH_PAM=NO" 343 "-DPLUGIN_AUTH_PAM_V1=NO" 344 "-DWITHOUT_OQGRAPH=1" 345 "-DWITHOUT_PLUGIN_S3=1" 346 ]; 347 348 preConfigure = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 349 patchShebangs scripts/mytop.sh 350 ''; 351 352 postInstall = 353 common.postInstall 354 + '' 355 rm -r "$out"/share/aclocal 356 chmod +x "$out"/bin/wsrep_sst_common 357 rm -f "$out"/bin/{mariadb-client-test,mariadb-test,mysql_client_test,mysqltest} 358 '' 359 + lib.optionalString withStorageMroonga '' 360 mv "$out"/share/{groonga,groonga-normalizer-mysql} "$out"/share/doc/mysql 361 '' 362 + lib.optionalString (!stdenv.hostPlatform.isDarwin && lib.versionAtLeast common.version "10.4") '' 363 mv "$out"/OFF/suite/plugins/pam/pam_mariadb_mtr.so "$out"/share/pam/lib/security 364 mv "$out"/OFF/suite/plugins/pam/mariadb_mtr "$out"/share/pam/etc/security 365 rm -r "$out"/OFF 366 ''; 367 368 CXXFLAGS = lib.optionalString stdenv.hostPlatform.isi686 "-fpermissive"; 369 370 passthru = { 371 inherit client; 372 server = finalAttrs.finalPackage; 373 }; 374 } 375 ); 376in 377self: { 378 # see https://mariadb.org/about/#maintenance-policy for EOLs 379 mariadb_106 = self.callPackage generic { 380 # Supported until 2026-07-06 381 version = "10.6.23"; 382 hash = "sha256-uvS/N6BR6JLnFyTudSiRrbfPxpzSjQhzXDYH0wxpPCM="; 383 }; 384 mariadb_1011 = self.callPackage generic { 385 # Supported until 2028-02-16 386 version = "10.11.14"; 387 hash = "sha256-ilccsU+x1ONmPY6Y89QgDAQvyLKkqqq0lYYN6ot9BS8="; 388 }; 389 mariadb_114 = self.callPackage generic { 390 # Supported until 2029-05-29 391 version = "11.4.8"; 392 hash = "sha256-UvpNyixfgK/BZn1SOifAYXbZhTIpimsMMe1zUF9J4Vw="; 393 }; 394 mariadb_118 = self.callPackage generic { 395 # Supported until 2028-06-04 396 version = "11.8.3"; 397 hash = "sha256-EBSoXHaN6PnpxtS/C0JhfzsViL4a03H3FnTqMrhxGcA="; 398 }; 399}