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 = "8.4.6"; 42 mysqlServerVersion = "8.4.6"; 43in 44stdenv.mkDerivation (finalAttrs: { 45 pname = "mysql-shell"; 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-oeUj3IvpbRilreEGmYZhKFygG29bRsCLJlQRDkDfL7c="; 52 }) 53 (fetchurl { 54 url = "https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell-${finalAttrs.version}-src.tar.gz"; 55 hash = "sha256-IUmWUW5rZcRvmolE+LjMaGPFa5abv1osIhTzm9BKt/w="; 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 preConfigure = '' 116 # Build MySQL 117 echo "Building mysqlclient mysqlxclient" 118 119 cmake -DWITH_SYSTEM_LIBS=ON -DWITH_FIDO=system -DWITH_ROUTER=OFF -DWITH_UNIT_TESTS=OFF \ 120 -DFORCE_UNSUPPORTED_COMPILER=1 -S ../mysql -B ../mysql/build 121 122 cmake --build ../mysql/build --parallel ''${NIX_BUILD_CORES:-1} --target mysqlclient mysqlxclient 123 124 cmakeFlagsArray+=( 125 "-DMYSQL_SOURCE_DIR=''${NIX_BUILD_TOP}/mysql" 126 "-DMYSQL_BUILD_DIR=''${NIX_BUILD_TOP}/mysql/build" 127 "-DMYSQL_CONFIG_EXECUTABLE=''${NIX_BUILD_TOP}/mysql/build/scripts/mysql_config" 128 "-DWITH_ZSTD=system" 129 "-DWITH_LZ4=system" 130 "-DWITH_ZLIB=system" 131 "-DWITH_PROTOBUF=system" 132 "-DHAVE_PYTHON=1" 133 ) 134 ''; 135 136 postFixup = '' 137 wrapProgram $out/bin/mysqlsh --set PYTHONPATH "${lib.makeSearchPath python3.sitePackages pythonDeps}" 138 ''; 139 140 meta = { 141 homepage = "https://dev.mysql.com/doc/mysql-shell/${lib.versions.majorMinor finalAttrs.version}/en/"; 142 description = "New command line scriptable shell for MySQL"; 143 license = lib.licenses.gpl2; 144 maintainers = with lib.maintainers; [ aaronjheng ]; 145 mainProgram = "mysqlsh"; 146 }; 147})