diff --git a/pkgs/by-name/do/dovecot/generic.nix b/pkgs/by-name/do/dovecot/generic.nix index 7c6c2768f505..40326745401c 100644 --- a/pkgs/by-name/do/dovecot/generic.nix +++ b/pkgs/by-name/do/dovecot/generic.nix @@ -7,6 +7,7 @@ autoreconfHook, stdenv, lib, + buildPackages, fetchzip, flex, bison, @@ -54,7 +55,20 @@ withLua ? false, lua5_3, }: - +let + # The `nativeBuildInputs` version of `mysql_config` emits headers and libraries for + # the build platform, not the host platform; `pkg-config` emits the correct versions. + fake_mysql_config = buildPackages.writeShellScriptBin "mysql_config" '' + if [ "$1" == "--include" ]; then + "$PKG_CONFIG" --cflags mysqlclient + elif [ "$1" == "--libs" ]; then + "$PKG_CONFIG" --libs mysqlclient + else + echo "fake_mysql_config: unsupported option: $1" >&2 + exit 1 + fi + ''; +in stdenv.mkDerivation (finalAttrs: { pname = "dovecot"; inherit version; @@ -66,7 +80,8 @@ stdenv.mkDerivation (finalAttrs: { pkg-config ] ++ lib.optionals (stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isDarwin) [ rpcsvc-proto ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ autoreconfHook ]; + ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ autoreconfHook ] + ++ lib.optional (withMySQL && lib.versionOlder version "2.4") fake_mysql_config; buildInputs = [ openssl