Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, pkg-config
4, cmake
5, fetchurl
6, git
7, cctools
8, developer_cmds
9, DarwinTools
10, makeWrapper
11, CoreServices
12, bison
13, openssl
14, protobuf
15, curl
16, zlib
17, libssh
18, zstd
19, lz4
20, boost
21, readline
22, libtirpc
23, rpcsvc-proto
24, libedit
25, libevent
26, icu
27, re2
28, ncurses
29, libfido2
30, python3
31, cyrus_sasl
32, openldap
33, antlr
34}:
35
36let
37 pythonDeps = with python3.pkgs; [ certifi paramiko pyyaml ];
38in
39stdenv.mkDerivation rec {
40 pname = "mysql-shell";
41 version = "8.0.33";
42
43 srcs = [
44 (fetchurl {
45 url = "https://cdn.mysql.com//Downloads/MySQL-Shell/mysql-shell-${version}-src.tar.gz";
46 hash = "sha256-ElcAOvyQjXNns35p4J+jnGu8orZR81Itz/fxYh7Usbs=";
47 })
48 (fetchurl {
49 url = "https://dev.mysql.com/get/Downloads/MySQL-${lib.versions.majorMinor version}/mysql-${version}.tar.gz";
50 hash = "sha256-liAC9dkG9C9AsnejnS25OTEkjB8H/49DEsKI5jgD3RI=";
51 })
52 ];
53
54 sourceRoot = "mysql-shell-${version}-src";
55
56 postPatch = ''
57 substituteInPlace ../mysql-${version}/cmake/libutils.cmake --replace /usr/bin/libtool libtool
58 substituteInPlace ../mysql-${version}/cmake/os/Darwin.cmake --replace /usr/bin/libtool libtool
59
60 substituteInPlace cmake/libutils.cmake --replace /usr/bin/libtool libtool
61 '';
62
63 nativeBuildInputs = [ pkg-config cmake git bison makeWrapper ]
64 ++ lib.optionals (!stdenv.isDarwin) [ rpcsvc-proto ]
65 ++ lib.optionals stdenv.isDarwin [ cctools developer_cmds DarwinTools ];
66
67 buildInputs = [
68 boost
69 curl
70 libedit
71 libssh
72 lz4
73 openssl
74 protobuf
75 readline
76 zlib
77 zstd
78 libevent
79 icu
80 re2
81 ncurses
82 libfido2
83 cyrus_sasl
84 openldap
85 python3
86 antlr.runtime.cpp
87 ] ++ pythonDeps
88 ++ lib.optionals stdenv.isLinux [ libtirpc ]
89 ++ lib.optionals stdenv.isDarwin [ CoreServices ];
90
91 preConfigure = ''
92 # Build MySQL
93 echo "Building mysqlclient mysqlxclient"
94
95 cmake -DWITH_BOOST=system -DWITH_SYSTEM_LIBS=ON -DWITH_ROUTER=OFF -DWITH_UNIT_TESTS=OFF \
96 -DFORCE_UNSUPPORTED_COMPILER=1 -S ../mysql-${version} -B ../mysql-${version}/build
97
98 cmake --build ../mysql-${version}/build --parallel ''${NIX_BUILD_CORES:-1} --target mysqlclient mysqlxclient
99 '';
100
101 cmakeFlags = [
102 "-DMYSQL_SOURCE_DIR=../mysql-${version}"
103 "-DMYSQL_BUILD_DIR=../mysql-${version}/build"
104 "-DMYSQL_CONFIG_EXECUTABLE=../../mysql-${version}/build/scripts/mysql_config"
105 "-DWITH_ZSTD=system"
106 "-DWITH_LZ4=system"
107 "-DWITH_ZLIB=system"
108 "-DWITH_PROTOBUF=${protobuf}"
109 "-DHAVE_V8=0" # V8 10.x required.
110 "-DHAVE_PYTHON=1"
111 ];
112
113 postFixup = ''
114 wrapProgram $out/bin/mysqlsh --set PYTHONPATH "${lib.makeSearchPath python3.sitePackages pythonDeps}"
115 '';
116
117 meta = with lib; {
118 homepage = "https://dev.mysql.com/doc/mysql-shell/${lib.versions.majorMinor version}/en/";
119 description = "A new command line scriptable shell for MySQL";
120 license = licenses.gpl2;
121 maintainers = with maintainers; [ aaronjheng ];
122 mainProgram = "mysqlsh";
123 };
124}