at master 3.7 kB view raw
1{ 2 lib, 3 stdenv, 4 pkg-config, 5 cmake, 6 fetchurl, 7 git, 8 cctools, 9 darwin, 10 makeWrapper, 11 bison, 12 openssl, 13 protobuf, 14 curl, 15 zlib, 16 libssh, 17 zstd, 18 lz4, 19 readline, 20 libtirpc, 21 rpcsvc-proto, 22 libedit, 23 libevent, 24 icu, 25 re2, 26 ncurses, 27 libfido2, 28 python3, 29 cyrus_sasl, 30 openldap, 31 antlr, 32}: 33 34let 35 pythonDeps = with python3.pkgs; [ 36 certifi 37 paramiko 38 pyyaml 39 ]; 40 41 mysqlShellVersion = "9.4.0"; 42 mysqlServerVersion = "9.4.0"; 43in 44stdenv.mkDerivation (finalAttrs: { 45 pname = "mysql-shell-innovation"; 46 version = mysqlShellVersion; 47 48 srcs = [ 49 (fetchurl { 50 url = "https://dev.mysql.com/get/Downloads/MySQL-${lib.versions.majorMinor mysqlServerVersion}/mysql-${mysqlServerVersion}.tar.gz"; 51 hash = "sha256-a7UJxU5YtUq776SeKW5yIPXnz+RGkUujYV9ZSWfPqSE="; 52 }) 53 (fetchurl { 54 url = "https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell-${finalAttrs.version}-src.tar.gz"; 55 hash = "sha256-BpiDGA3Lxf/MrKqtPSA+apFNZx9N805PYYVa+2vQxPE="; 56 }) 57 ]; 58 59 sourceRoot = "mysql-shell-${finalAttrs.version}-src"; 60 61 postUnpack = '' 62 mv mysql-${mysqlServerVersion} mysql 63 ''; 64 65 patches = [ 66 # No openssl bundling on macOS. It's not working. 67 # See https://github.com/mysql/mysql-shell/blob/5b84e0be59fc0e027ef3f4920df15f7be97624c1/cmake/ssl.cmake#L53 68 ./no-openssl-bundling.patch 69 ]; 70 71 postPatch = '' 72 substituteInPlace ../mysql/cmake/libutils.cmake --replace-fail /usr/bin/libtool libtool 73 substituteInPlace ../mysql/cmake/os/Darwin.cmake --replace-fail /usr/bin/libtool libtool 74 75 substituteInPlace cmake/libutils.cmake --replace-fail /usr/bin/libtool libtool 76 ''; 77 78 nativeBuildInputs = [ 79 pkg-config 80 cmake 81 git 82 bison 83 makeWrapper 84 ] 85 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ] 86 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 87 cctools 88 darwin.DarwinTools 89 ]; 90 91 buildInputs = [ 92 curl 93 libedit 94 libssh 95 lz4 96 openssl 97 protobuf 98 readline 99 zlib 100 zstd 101 libevent 102 icu 103 re2 104 ncurses 105 libfido2 106 cyrus_sasl 107 openldap 108 python3 109 antlr.runtime.cpp 110 ] 111 ++ pythonDeps 112 ++ lib.optionals stdenv.hostPlatform.isLinux [ libtirpc ] 113 ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.libutil ]; 114 115 env = { 116 ${if stdenv.cc.isGNU then "NIX_CFLAGS_COMPILE" else null} = "-Wno-error=maybe-uninitialized"; 117 }; 118 119 preConfigure = '' 120 # Build MySQL 121 echo "Building mysqlclient mysqlxclient" 122 123 cmake -DWITH_SYSTEM_LIBS=ON -DWITH_FIDO=system -DWITH_ROUTER=ON -DWITH_UNIT_TESTS=OFF \ 124 -DFORCE_UNSUPPORTED_COMPILER=1 -S ../mysql -B ../mysql/build 125 126 cmake --build ../mysql/build --parallel ''${NIX_BUILD_CORES:-1} \ 127 --target mysqlclient mysqlxclient mysqlbinlog mysql_binlog_event_standalone mysqlrouter_all 128 129 cmakeFlagsArray+=( 130 "-DMYSQL_SOURCE_DIR=''${NIX_BUILD_TOP}/mysql" 131 "-DMYSQL_BUILD_DIR=''${NIX_BUILD_TOP}/mysql/build" 132 "-DMYSQL_CONFIG_EXECUTABLE=''${NIX_BUILD_TOP}/mysql/build/scripts/mysql_config" 133 "-DWITH_ZSTD=system" 134 "-DWITH_LZ4=system" 135 "-DWITH_ZLIB=system" 136 "-DWITH_PROTOBUF=system" 137 "-DHAVE_PYTHON=1" 138 ) 139 ''; 140 141 postFixup = '' 142 wrapProgram $out/bin/mysqlsh --set PYTHONPATH "${lib.makeSearchPath python3.sitePackages pythonDeps}" 143 ''; 144 145 meta = { 146 homepage = "https://dev.mysql.com/doc/mysql-shell/${lib.versions.majorMinor finalAttrs.version}/en/"; 147 description = "New command line scriptable shell for MySQL"; 148 license = lib.licenses.gpl2; 149 maintainers = with lib.maintainers; [ aaronjheng ]; 150 platforms = lib.platforms.linux ++ lib.platforms.darwin; 151 mainProgram = "mysqlsh"; 152 }; 153})