@@ -1,6 +1,6 @@
11{ stdenv, lib, fetchurl, pkgconfig, pcre, perl, flex, bison, gettext, libpcap, libnl, c-ares
22, gnutls, libgcrypt, libgpgerror, geoip, openssl, lua5, makeDesktopItem, python, libcap, glib
3−, libssh, zlib, cmake, extra-cmake-modules, fetchpatch
3+, libssh, zlib, cmake, extra-cmake-modules, fetchpatch, makeWrapper
44, withGtk ? false, gtk3 ? null, librsvg ? null, gsettings-desktop-schemas ? null, wrapGAppsHook ? null
55, withQt ? false, qt5 ? null
66, ApplicationServices, SystemConfiguration, gmp
@@ -26,6 +26,8 @@ in stdenv.mkDerivation {
2626 cmakeFlags = [
2727 "-DBUILD_wireshark_gtk=${if withGtk then "ON" else "OFF"}"
2828 "-DBUILD_wireshark=${if withQt then "ON" else "OFF"}"
29+ "-DENABLE_QT5=${if withQt then "ON" else "OFF"}"
30+ "-DENABLE_APPLICATION_BUNDLE=${if withQt && stdenv.isDarwin then "ON" else "OFF"}"
2931 ];
3032
3133 nativeBuildInputs = [
@@ -34,11 +36,12 @@ in stdenv.mkDerivation {
3436
3537 buildInputs = [
3638 gettext pcre perl libpcap lua5 libssh openssl libgcrypt
37− libgpgerror gnutls geoip c-ares python glib zlib
39+ libgpgerror gnutls geoip c-ares python glib zlib makeWrapper
3840 ] ++ optionals withQt (with qt5; [ qtbase qtmultimedia qtsvg qttools ])
3941 ++ optionals withGtk [ gtk3 librsvg gsettings-desktop-schemas ]
4042 ++ optionals stdenv.isLinux [ libcap libnl ]
41− ++ optionals stdenv.isDarwin [ SystemConfiguration ApplicationServices gmp ];
43+ ++ optionals stdenv.isDarwin [ SystemConfiguration ApplicationServices gmp ]
44+ ++ optionals (withQt && stdenv.isDarwin) (with qt5; [ qtmacextras ]);
4245
4346 patches = [ ./wireshark-lookup-dumpcap-in-path.patch ]
4447 # https://code.wireshark.org/review/#/c/23728/
@@ -46,9 +49,24 @@ in stdenv.mkDerivation {
4649 name = "fix-timeout.patch";
4750 url = "https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commitdiff_plain;h=8b5b843fcbc3e03e0fc45f3caf8cf5fc477e8613;hp=94af9724d140fd132896b650d10c4d060788e4f0";
4851 sha256 = "1g2dm7lwsnanwp68b9xr9swspx7hfj4v3z44sz3yrfmynygk8zlv";
49− });
52+ })
53+ ++ stdenv.lib.optional stdenv.isDarwin ./cmake.patch;
5054
51− postInstall = optionalString (withQt || withGtk) ''
55+ postInstall = if stdenv.isDarwin then ''
56+ ${optionalString withQt ''
57+ mkdir -p $out/Applications
58+ mv $out/bin/Wireshark.app $out/Applications/Wireshark.app
59+
60+ for so in $out/Applications/Wireshark.app/Contents/PlugIns/wireshark/*.so; do
61+ install_name_tool $so -change libwireshark.10.dylib $out/lib/libwireshark.10.dylib
62+ install_name_tool $so -change libwiretap.7.dylib $out/lib/libwiretap.7.dylib
63+ install_name_tool $so -change libwsutil.8.dylib $out/lib/libwsutil.8.dylib
64+ done
65+
66+ wrapProgram $out/Applications/Wireshark.app/Contents/MacOS/Wireshark \
67+ --set QT_PLUGIN_PATH ${qt5.qtbase.bin}/${qt5.qtbase.qtPluginPrefix}
68+ ''}
69+ '' else optionalString (withQt || withGtk) ''
5270 ${optionalString withGtk ''
5371 install -Dm644 -t $out/share/applications ../wireshark-gtk.desktop
5472 ''}
@@ -75,7 +93,7 @@ in stdenv.mkDerivation {
7593 experts. It runs on UNIX, macOS and Windows.
7694 '';
7795
78− platforms = platforms.linux;
96+ platforms = platforms.linux ++ platforms.darwin;
7997 maintainers = with maintainers; [ bjornfor fpletz ];
8098 };
8199}