Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 138 lines 3.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fetchpatch, 6 bison, 7 cmake, 8 pkg-config, 9 boost, 10 icu, 11 libedit, 12 libevent, 13 lz4, 14 ncurses, 15 openssl, 16 protobuf, 17 re2, 18 readline, 19 zlib, 20 zstd, 21 libfido2, 22 numactl, 23 cctools, 24 developer_cmds, 25 libtirpc, 26 rpcsvc-proto, 27 curl, 28 DarwinTools, 29 nixosTests, 30}: 31 32stdenv.mkDerivation (finalAttrs: { 33 pname = "mysql"; 34 version = "8.0.42"; 35 36 src = fetchurl { 37 url = "https://dev.mysql.com/get/Downloads/MySQL-${lib.versions.majorMinor finalAttrs.version}/mysql-${finalAttrs.version}.tar.gz"; 38 hash = "sha256-XrIsIMILdlxYlMkBBIW9B9iptuv7YovP0wYHAXFVJv4="; 39 }; 40 41 nativeBuildInputs = [ 42 bison 43 cmake 44 pkg-config 45 protobuf 46 ] 47 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ]; 48 49 patches = [ 50 ./no-force-outline-atomics.patch # Do not force compilers to turn on -moutline-atomics switch 51 # Fix compilation with LLVM 19, adapted from https://github.com/mysql/mysql-server/commit/3a51d7fca76e02257f5c42b6a4fc0c5426bf0421 52 # in https://github.com/NixOS/nixpkgs/pull/374591#issuecomment-2615855076 53 ./libcpp-fixes.patch 54 (fetchpatch { 55 url = "https://github.com/mysql/mysql-server/commit/4a5c00d26f95faa986ffed7a15ee15e868e9dcf2.patch"; 56 hash = "sha256-MEl1lQlDYtFjHk0+S02RQFnxMr+YeFxAyNjpDtVHyeE="; 57 }) 58 ]; 59 60 ## NOTE: MySQL upstream frequently twiddles the invocations of libtool. When updating, you might proactively grep for libtool references. 61 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' 62 substituteInPlace cmake/libutils.cmake --replace-fail /usr/bin/libtool ${cctools}/bin/libtool 63 substituteInPlace cmake/os/Darwin.cmake --replace-fail /usr/bin/libtool ${cctools}/bin/libtool 64 substituteInPlace cmake/package_name.cmake --replace-fail "COMMAND sw_vers" "COMMAND ${DarwinTools}/bin/sw_vers" 65 ''; 66 67 buildInputs = [ 68 boost 69 (curl.override { inherit openssl; }) 70 icu 71 libedit 72 libevent 73 lz4 74 ncurses 75 openssl 76 protobuf 77 re2 78 readline 79 zlib 80 zstd 81 libfido2 82 ] 83 ++ lib.optionals stdenv.hostPlatform.isLinux [ 84 numactl 85 libtirpc 86 ] 87 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 88 developer_cmds 89 ]; 90 91 strictDeps = true; 92 93 outputs = [ 94 "out" 95 "static" 96 ]; 97 98 cmakeFlags = [ 99 "-DFORCE_UNSUPPORTED_COMPILER=1" # To configure on Darwin. 100 "-DWITH_ROUTER=OFF" # It may be packaged separately. 101 "-DWITH_SYSTEM_LIBS=ON" 102 "-DWITH_UNIT_TESTS=OFF" 103 "-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock" 104 "-DMYSQL_DATADIR=/var/lib/mysql" 105 "-DINSTALL_INFODIR=share/mysql/docs" 106 "-DINSTALL_MANDIR=share/man" 107 "-DINSTALL_PLUGINDIR=lib/mysql/plugin" 108 "-DINSTALL_INCLUDEDIR=include/mysql" 109 "-DINSTALL_DOCREADMEDIR=share/mysql" 110 "-DINSTALL_SUPPORTFILESDIR=share/mysql" 111 "-DINSTALL_MYSQLSHAREDIR=share/mysql" 112 "-DINSTALL_MYSQLTESTDIR=" 113 "-DINSTALL_DOCDIR=share/mysql/docs" 114 "-DINSTALL_SHAREDIR=share/mysql" 115 ]; 116 117 postInstall = '' 118 moveToOutput "lib/*.a" $static 119 so=${stdenv.hostPlatform.extensions.sharedLibrary} 120 ln -s libmysqlclient$so $out/lib/libmysqlclient_r$so 121 ''; 122 123 passthru = { 124 client = finalAttrs.finalPackage; 125 connector-c = finalAttrs.finalPackage; 126 server = finalAttrs.finalPackage; 127 mysqlVersion = lib.versions.majorMinor finalAttrs.version; 128 tests = nixosTests.mysql.mysql80; 129 }; 130 131 meta = with lib; { 132 homepage = "https://www.mysql.com/"; 133 description = "World's most popular open source database"; 134 license = licenses.gpl2Only; 135 maintainers = with maintainers; [ orivej ]; 136 platforms = platforms.unix; 137 }; 138})