lol

mariadb: completely separate a server-less build

libmysqlclient is all that most closures need; now it's smaller and
quick to build. For cases that need a server (via executable or lib),
there's a full build for now; later it could be slimmed by removing the
client stuff.

+109 -95
+108 -94
pkgs/servers/sql/mariadb/default.nix
··· 1 - { stdenv, fetchurl, cmake, ncurses, zlib, xz, lzo, lz4, bzip2, snappy 1 + { stdenv, fetchurl, cmake, pkgconfig, ncurses, zlib, xz, lzo, lz4, bzip2, snappy 2 2 , openssl, pcre, boost, judy, bison, libxml2 3 3 , libaio, libevent, groff, jemalloc, cracklib, systemd, numactl, perl 4 4 , fixDarwinDylibNames, cctools, CoreServices 5 - , makeWrapper 6 5 }: 7 6 8 7 with stdenv.lib; 9 - stdenv.mkDerivation rec { 10 - name = "mariadb-${version}"; 11 - version = "10.1.9"; 8 + 9 + let # in mariadb # spans the whole file 10 + 11 + mariadb = { 12 + inherit client # libmysqlclient.so in .out, necessary headers in .dev and utils in .bin 13 + server; # currently a full build, including everything in `client` again 14 + lib = client; # compat. with the old mariadb split 15 + }; 16 + 17 + 18 + common = rec { # attributes common to both builds 19 + version = "10.1.16"; 12 20 13 21 src = fetchurl { 14 22 url = "https://downloads.mariadb.org/interstitial/mariadb-${version}/source/mariadb-${version}.tar.gz"; 15 - sha256 = "0471vwg9c5c17m7679krjha16ib6d48fcsphkchb9v9cf8k5i74f"; 23 + sha256 = "14s3wq1c25n62n75hkixl8n7cni4m73w055nsx4czm655k33bjv7"; 16 24 }; 17 25 26 + prePatch = '' 27 + substituteInPlace cmake/libutils.cmake \ 28 + --replace /usr/bin/libtool libtool 29 + sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt 30 + ''; 31 + 32 + patches = stdenv.lib.optional stdenv.isDarwin ./my_context_asm.patch; 33 + 34 + nativeBuildInputs = [ cmake pkgconfig ]; 35 + 18 36 buildInputs = [ 19 - cmake ncurses openssl zlib xz lzo lz4 bzip2 20 - # temporary due to https://mariadb.atlassian.net/browse/MDEV-9000 21 - (if stdenv.is64bit then snappy else null) 22 - pcre libxml2 boost judy bison libevent cracklib 23 - makeWrapper 37 + ncurses openssl zlib pcre 24 38 ] ++ stdenv.lib.optionals stdenv.isLinux [ jemalloc libaio systemd ] 25 - ++ stdenv.lib.optionals (stdenv.isLinux && !stdenv.isArm) [ numactl ] 26 39 ++ stdenv.lib.optionals stdenv.isDarwin [ perl fixDarwinDylibNames cctools CoreServices ]; 27 - 28 - patches = stdenv.lib.optional stdenv.isDarwin ./my_context_asm.patch; 29 40 30 41 cmakeFlags = [ 31 42 "-DBUILD_CONFIG=mysql_release" 43 + "-DMANUFACTURER=NixOS.org" 32 44 "-DDEFAULT_CHARSET=utf8" 33 45 "-DDEFAULT_COLLATION=utf8_general_ci" 34 - "-DENABLED_LOCAL_INFILE=ON" 46 + "-DSECURITY_HARDENED=ON" 47 + 35 48 "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock" 49 + "-DINSTALL_MYSQLSHAREDIR=share/mysql" 50 + 51 + "-DWITH_ZLIB=system" 52 + "-DWITH_SSL=system" 53 + "-DWITH_PCRE=system" 54 + ] 55 + ++ optional stdenv.isDarwin "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib" 56 + ; 57 + 58 + preConfigure = '' 59 + cmakeFlags="$cmakeFlags -DINSTALL_INCLUDEDIR=''${!outputDev}/include/mysql" 60 + ''; 61 + 62 + postInstall = '' 63 + rm "$out"/lib/*.a 64 + find "''${!outputBin}/bin" -name '*test*' -delete 65 + ''; 66 + 67 + passthru.mysqlVersion = "5.6"; 68 + 69 + meta = with stdenv.lib; { 70 + description = "An enhanced, drop-in replacement for MySQL"; 71 + homepage = https://mariadb.org/; 72 + license = licenses.gpl2; 73 + maintainers = with maintainers; [ thoughtpolice wkennington ]; 74 + platforms = platforms.all; 75 + }; 76 + }; 77 + 78 + 79 + client = stdenv.mkDerivation (common // { 80 + name = "mariadb-client-${common.version}"; 81 + 82 + outputs = [ "dev" "out" "bin" ]; 83 + 84 + propagatedBuildInputs = [ openssl zlib ]; # required from mariadb.pc 85 + 86 + cmakeFlags = common.cmakeFlags ++ [ 87 + "-DWITHOUT_SERVER=ON" 88 + ]; 89 + 90 + preConfigure = common.preConfigure + '' 91 + cmakeFlags="$cmakeFlags \ 92 + -DINSTALL_BINDIR=$bin/bin -DINSTALL_SCRIPTDIR=$bin/bin \ 93 + -DINSTALL_SUPPORTFILESDIR=$bin/share/mysql \ 94 + -DINSTALL_DOCDIR=$bin/share/doc/mysql -DINSTALL_DOCREADMEDIR=$bin/share/doc/mysql \ 95 + " 96 + ''; 97 + 98 + # prevent cycle; it needs to reference $dev 99 + postInstall = common.postInstall + '' 100 + moveToOutput bin/mysql_config "$dev" 101 + ''; 102 + 103 + enableParallelBuilding = true; # the client should be OK 104 + }); 105 + 106 + 107 + server = stdenv.mkDerivation (common // { 108 + name = "mariadb-${common.version}"; 109 + 110 + nativeBuildInputs = common.nativeBuildInputs ++ [ bison ]; 111 + 112 + buildInputs = common.buildInputs ++ [ 113 + xz lzo lz4 bzip2 snappy 114 + libxml2 boost judy libevent cracklib 115 + ] 116 + ++ optionals (stdenv.isLinux && !stdenv.isArm) [ numactl ] 117 + ; 118 + 119 + cmakeFlags = common.cmakeFlags ++ [ 36 120 "-DMYSQL_DATADIR=/var/lib/mysql" 37 121 "-DINSTALL_SYSCONFDIR=etc/mysql" 38 122 "-DINSTALL_INFODIR=share/mysql/docs" 39 123 "-DINSTALL_MANDIR=share/man" 40 124 "-DINSTALL_PLUGINDIR=lib/mysql/plugin" 41 125 "-DINSTALL_SCRIPTDIR=bin" 42 - "-DINSTALL_INCLUDEDIR=include/mysql" 43 - "-DINSTALL_DOCREADMEDIR=share/mysql" 44 126 "-DINSTALL_SUPPORTFILESDIR=share/mysql" 45 - "-DINSTALL_MYSQLSHAREDIR=share/mysql" 46 - "-DINSTALL_DOCDIR=share/mysql/docs" 127 + "-DINSTALL_DOCREADMEDIR=share/doc/mysql" 128 + "-DINSTALL_DOCDIR=share/doc/mysql" 47 129 "-DINSTALL_SHAREDIR=share/mysql" 130 + 131 + "-DENABLED_LOCAL_INFILE=ON" 48 132 "-DWITH_READLINE=ON" 49 - "-DWITH_ZLIB=system" 50 - "-DWITH_SSL=system" 51 - "-DWITH_PCRE=system" 52 - "-DWITH_EMBEDDED_SERVER=yes" 53 133 "-DWITH_EXTRA_CHARSETS=complex" 54 134 "-DWITH_EMBEDDED_SERVER=ON" 55 135 "-DWITH_ARCHIVE_STORAGE_ENGINE=1" ··· 58 138 "-DWITH_PARTITION_STORAGE_ENGINE=1" 59 139 "-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1" 60 140 "-DWITHOUT_FEDERATED_STORAGE_ENGINE=1" 61 - "-DSECURITY_HARDENED=ON" 62 141 "-DWITH_WSREP=ON" 63 142 ] ++ stdenv.lib.optionals stdenv.isDarwin [ 64 143 "-DWITHOUT_OQGRAPH_STORAGE_ENGINE=1" 65 144 "-DWITHOUT_TOKUDB=1" 66 - "-DCURSES_LIBRARY=${ncurses.out}/lib/libncurses.dylib" 67 145 ]; 68 146 69 - # fails to find lex_token.h sometimes 70 - enableParallelBuilding = false; 71 - 72 - outputs = [ "out" "lib" ]; 73 - setOutputFlags = false; 74 - moveToDev = false; 75 - 76 - prePatch = '' 77 - substituteInPlace cmake/libutils.cmake \ 78 - --replace /usr/bin/libtool libtool 79 - sed -i "s,SET(DEFAULT_MYSQL_HOME.*$,SET(DEFAULT_MYSQL_HOME /not/a/real/dir),g" CMakeLists.txt 80 - sed -i "s,SET(PLUGINDIR.*$,SET(PLUGINDIR $lib/lib/mysql/plugin),g" CMakeLists.txt 81 - 82 - sed -i "s,SET(pkgincludedir.*$,SET(pkgincludedir $lib/include),g" scripts/CMakeLists.txt 83 - sed -i "s,SET(pkglibdir.*$,SET(pkglibdir $lib/lib),g" scripts/CMakeLists.txt 84 - sed -i "s,SET(pkgplugindir.*$,SET(pkgplugindir $lib/lib/mysql/plugin),g" scripts/CMakeLists.txt 85 - 86 - sed -i "s,set(libdir.*$,SET(libdir $lib/lib),g" storage/mroonga/vendor/groonga/CMakeLists.txt 87 - sed -i "s,set(includedir.*$,SET(includedir $lib/include),g" storage/mroonga/vendor/groonga/CMakeLists.txt 88 - sed -i "/\"\$[{]CMAKE_INSTALL_PREFIX}\/\$[{]GRN_RELATIVE_PLUGINS_DIR}\"/d" storage/mroonga/vendor/groonga/CMakeLists.txt 89 - sed -i "s,set(GRN_PLUGINS_DIR.*$,SET(GRN_PLUGINS_DIR $lib/\$\{GRN_RELATIVE_PLUGINS_DIR}),g" storage/mroonga/vendor/groonga/CMakeLists.txt 90 - sed -i 's,[^"]*/var/log,/var/log,g' storage/mroonga/vendor/groonga/CMakeLists.txt 147 + postInstall = common.postInstall + '' 148 + rm -r "$out"/{mysql-test,sql-bench,data} # Don't need testing data 149 + rm "$out"/share/man/man1/mysql-test-run.pl.1 91 150 ''; 92 - 93 - postInstall = '' 94 - substituteInPlace $out/bin/mysql_install_db \ 95 - --replace basedir=\"\" basedir=\"$out\" 96 - 97 - # Wrap mysqld with --basedir, but as last flag 98 - wrapProgram $out/bin/mysqld 99 - sed -i "s,\(^exec.*$\),\1 --basedir=$out,g" $out/bin/mysqld 100 - 101 - # Remove superfluous files 102 - rm -r $out/mysql-test $out/sql-bench $out/data # Don't need testing data 103 - rm $out/share/man/man1/mysql-test-run.pl.1 104 - rm $out/bin/rcmysql # Not needed with nixos units 105 - rm $out/bin/mysqlbug # Encodes a path to gcc and not really useful 106 - find $out/bin -name \*test\* -exec rm {} \; 107 - 108 - # Separate libs and includes into their own derivation 109 - mkdir -p $lib 110 - mv $out/lib $lib 111 - mv $out/include $lib 112 - 113 - # Fix the mysql_config 114 - sed -i $out/bin/mysql_config \ 115 - -e 's,-lz,-L${zlib.out}/lib -lz,g' \ 116 - -e 's,-lssl,-L${openssl.out}/lib -lssl,g' 151 + }); 117 152 118 - # Add mysql_config to libs since configure scripts use it 119 - mkdir -p $lib/bin 120 - cp $out/bin/mysql_config $lib/bin 121 - sed -i "/\(execdir\|bindir\)/ s,'[^\"']*',$lib/bin,g" $lib/bin/mysql_config 153 + in mariadb 122 154 123 - # Make sure to propagate lib for compatability 124 - mkdir -p $out/nix-support 125 - echo "$lib" > $out/nix-support/propagated-native-build-inputs 126 - 127 - # Don't install static libraries. 128 - rm $lib/lib/libmysqlclient.a $lib/lib/libmysqld.a 129 - ''; 130 - 131 - passthru.mysqlVersion = "5.6"; 132 - 133 - meta = with stdenv.lib; { 134 - description = "An enhanced, drop-in replacement for MySQL"; 135 - homepage = https://mariadb.org/; 136 - license = stdenv.lib.licenses.gpl2; 137 - maintainers = with stdenv.lib.maintainers; [ thoughtpolice wkennington ]; 138 - platforms = stdenv.lib.platforms.all; 139 - }; 140 - }
+1 -1
pkgs/top-level/all-packages.nix
··· 10438 10438 }; 10439 10439 10440 10440 mysql = mariadb; 10441 - libmysql = mysql.lib; 10441 + libmysql = mysql.client; # `libmysql` is a slight misnomer ATM 10442 10442 10443 10443 mysql_jdbc = callPackage ../servers/sql/mysql/jdbc { }; 10444 10444