diff --git a/pkgs/development/tools/mysql-shell/8.nix b/pkgs/development/tools/mysql-shell/8.nix new file mode 100644 index 000000000000..2f8983572f29 --- /dev/null +++ b/pkgs/development/tools/mysql-shell/8.nix @@ -0,0 +1,133 @@ +{ lib +, stdenv +, pkg-config +, cmake +, fetchurl +, git +, cctools +, DarwinTools +, makeWrapper +, CoreServices +, bison +, openssl +, protobuf +, curl +, zlib +, libssh +, zstd +, lz4 +, readline +, libtirpc +, rpcsvc-proto +, libedit +, libevent +, icu +, re2 +, ncurses +, libfido2 +, python3 +, cyrus_sasl +, openldap +, antlr +}: + +let + pythonDeps = with python3.pkgs; [ certifi paramiko pyyaml ]; + + mysqlShellVersion = "8.4.1"; + mysqlServerVersion = "8.4.1"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "mysql-shell"; + version = mysqlShellVersion; + + srcs = [ + (fetchurl { + url = "https://dev.mysql.com/get/Downloads/MySQL-${lib.versions.majorMinor mysqlServerVersion}/mysql-${mysqlServerVersion}.tar.gz"; + hash = "sha256-20Hxl9cXDFTX7cDQyaJzDCJfSvBeztD2S+z5u2wRAT4="; + }) + (fetchurl { + url = "https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell-${finalAttrs.version}-src.tar.gz"; + hash = "sha256-wTwoaoaCrTQqaqgE35Sg8zn8HqjsjQowbtgMZTpkYQU="; + }) + ]; + + sourceRoot = "mysql-shell-${finalAttrs.version}-src"; + + postUnpack = '' + mv mysql-${mysqlServerVersion} mysql + ''; + + patches = [ + # No openssl bundling on macOS. It's not working. + # See https://github.com/mysql/mysql-shell/blob/5b84e0be59fc0e027ef3f4920df15f7be97624c1/cmake/ssl.cmake#L53 + ./no-openssl-bundling.patch + ]; + + postPatch = '' + substituteInPlace ../mysql/cmake/libutils.cmake --replace-fail /usr/bin/libtool libtool + substituteInPlace ../mysql/cmake/os/Darwin.cmake --replace-fail /usr/bin/libtool libtool + + substituteInPlace cmake/libutils.cmake --replace-fail /usr/bin/libtool libtool + ''; + + nativeBuildInputs = [ pkg-config cmake git bison makeWrapper ] + ++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ] + ++ lib.optionals stdenv.isDarwin [ cctools DarwinTools ]; + + buildInputs = [ + curl + libedit + libssh + lz4 + openssl + protobuf + readline + zlib + zstd + libevent + icu + re2 + ncurses + libfido2 + cyrus_sasl + openldap + python3 + antlr.runtime.cpp + ] ++ pythonDeps + ++ lib.optionals stdenv.isLinux [ libtirpc ] + ++ lib.optionals stdenv.isDarwin [ CoreServices ]; + + preConfigure = '' + # Build MySQL + echo "Building mysqlclient mysqlxclient" + + cmake -DWITH_SYSTEM_LIBS=ON -DWITH_FIDO=system -DWITH_ROUTER=OFF -DWITH_UNIT_TESTS=OFF \ + -DFORCE_UNSUPPORTED_COMPILER=1 -S ../mysql -B ../mysql/build + + cmake --build ../mysql/build --parallel ''${NIX_BUILD_CORES:-1} --target mysqlclient mysqlxclient + + cmakeFlagsArray+=( + "-DMYSQL_SOURCE_DIR=''${NIX_BUILD_TOP}/mysql" + "-DMYSQL_BUILD_DIR=''${NIX_BUILD_TOP}/mysql/build" + "-DMYSQL_CONFIG_EXECUTABLE=''${NIX_BUILD_TOP}/mysql/build/scripts/mysql_config" + "-DWITH_ZSTD=system" + "-DWITH_LZ4=system" + "-DWITH_ZLIB=system" + "-DWITH_PROTOBUF=system" + "-DHAVE_PYTHON=1" + ) + ''; + + postFixup = '' + wrapProgram $out/bin/mysqlsh --set PYTHONPATH "${lib.makeSearchPath python3.sitePackages pythonDeps}" + ''; + + meta = with lib; { + homepage = "https://dev.mysql.com/doc/mysql-shell/${lib.versions.majorMinor finalAttrs.version}/en/"; + description = "New command line scriptable shell for MySQL"; + license = licenses.gpl2; + maintainers = with maintainers; [ aaronjheng ]; + mainProgram = "mysqlsh"; + }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f4fbdcc4de8b..936c57e3a9ff 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1061,6 +1061,18 @@ with pkgs; protobuf = protobuf_24; }; + inherit ({ + mysql-shell_8 = callPackage ../development/tools/mysql-shell/8.nix { + inherit (darwin) cctools DarwinTools; + inherit (darwin.apple_sdk.frameworks) CoreServices; + antlr = antlr4_10; + icu = icu73; + protobuf = protobuf_24; + }; + }) + mysql-shell_8 + ; + mysql-shell-innovation = callPackage ../development/tools/mysql-shell/innovation.nix { inherit (darwin) cctools DarwinTools; inherit (darwin.apple_sdk.frameworks) CoreServices;