diff --git a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix index 5e8a632cbd44..b0a04a36befd 100644 --- a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix +++ b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix @@ -1,17 +1,20 @@ -{ mkDerivation -, lib +{ lib +, stdenv , fetchFromGitHub , callPackage , pkg-config , cmake , ninja +, clang , python3 , wrapGAppsHook , wrapQtAppsHook +, removeReferencesTo +, extra-cmake-modules , qtbase , qtimageformats -, gtk3 -, libsForQt5 +, qtsvg +, kwayland , lz4 , xxHash , ffmpeg @@ -25,53 +28,74 @@ , hunspell , glibmm , webkitgtk - # Transitive dependencies: -, pcre -, xorg -, util-linux -, libselinux -, libsepol -, libepoxy -, at-spi2-core -, libXtst -, libthai -, libdatrie +, jemalloc +, rnnoise +, abseil-cpp +, microsoft_gsl +, wayland +, withWebKit ? false }: with lib; let - tg_owt = callPackage ./tg_owt.nix { }; + tg_owt = callPackage ./tg_owt.nix { + abseil-cpp = abseil-cpp.override { + cxxStandard = "20"; + }; + }; in -mkDerivation rec { +stdenv.mkDerivation rec { pname = "kotatogram-desktop"; - version = "1.4.1"; + version = "1.4.9"; src = fetchFromGitHub { owner = "kotatogram"; repo = "kotatogram-desktop"; rev = "k${version}"; - sha256 = "07z56gz3sk45n5j0gw9p9mxrbwixxsmp7lvqc6lqnxmglz6knc1d"; + sha256 = "sha256-6bF/6fr8mJyyVg53qUykysL7chuewtJB8E22kVyxjHw="; fetchSubmodules = true; }; + patches = [ + ./shortcuts-binary-path.patch + ]; + postPatch = '' - substituteInPlace Telegram/CMakeLists.txt \ - --replace '"''${TDESKTOP_LAUNCHER_BASENAME}.appdata.xml"' '"''${TDESKTOP_LAUNCHER_BASENAME}.metainfo.xml"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \ + --replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \ + --replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp \ + --replace '"libpulse.so.0"' '"${libpulseaudio}/lib/libpulse.so.0"' + '' + optionalString withWebKit '' + substituteInPlace Telegram/lib_webview/webview/platform/linux/webview_linux_webkit_gtk.cpp \ + --replace '"libwebkit2gtk-4.0.so.37"' '"${webkitgtk}/lib/libwebkit2gtk-4.0.so.37"' ''; # We want to run wrapProgram manually (with additional parameters) dontWrapGApps = true; - dontWrapQtApps = true; + dontWrapQtApps = withWebKit; - nativeBuildInputs = [ pkg-config cmake ninja python3 wrapGAppsHook wrapQtAppsHook ]; + nativeBuildInputs = [ + pkg-config + cmake + ninja + # to build bundled libdispatch + clang + python3 + wrapQtAppsHook + removeReferencesTo + extra-cmake-modules + ] ++ optionals withWebKit [ + wrapGAppsHook + ]; buildInputs = [ qtbase qtimageformats - gtk3 - libsForQt5.kwayland - libsForQt5.libdbusmenu + qtsvg + kwayland lz4 xxHash ffmpeg @@ -84,24 +108,29 @@ mkDerivation rec { tl-expected hunspell glibmm - webkitgtk + jemalloc + rnnoise tg_owt - # Transitive dependencies: - pcre - xorg.libXdmcp - util-linux - libselinux - libsepol - libepoxy - at-spi2-core - libXtst - libthai - libdatrie + microsoft_gsl + wayland + ] ++ optionals withWebKit [ + webkitgtk ]; - cmakeFlags = [ "-DTDESKTOP_API_TEST=ON" ]; + enableParallelBuilding = true; - postFixup = '' + cmakeFlags = [ + "-DTDESKTOP_API_TEST=ON" + "-DDESKTOP_APP_QT6=OFF" + ]; + + preFixup = '' + remove-references-to -t ${stdenv.cc.cc} $out/bin/kotatogram-desktop + remove-references-to -t ${microsoft_gsl} $out/bin/kotatogram-desktop + remove-references-to -t ${tg_owt.dev} $out/bin/kotatogram-desktop + ''; + + postFixup = optionalString withWebKit '' # We also use gappsWrapperArgs from wrapGAppsHook. wrapProgram $out/bin/kotatogram-desktop \ "''${gappsWrapperArgs[@]}" \ @@ -122,7 +151,7 @@ mkDerivation rec { license = licenses.gpl3; platforms = platforms.linux; homepage = "https://kotatogram.github.io"; - changelog = "https://github.com/kotatogram/kotatogram-desktop/releases/tag/k{ver}"; + changelog = "https://github.com/kotatogram/kotatogram-desktop/releases/tag/k{version}"; maintainers = with maintainers; [ ilya-fedin ]; }; } diff --git a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/shortcuts-binary-path.patch b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/shortcuts-binary-path.patch new file mode 100644 index 000000000000..f173a64f141a --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/shortcuts-binary-path.patch @@ -0,0 +1,38 @@ +diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp +index 2a092c6ea..de46dd269 100644 +--- a/Telegram/SourceFiles/core/application.cpp ++++ b/Telegram/SourceFiles/core/application.cpp +@@ -1173,7 +1173,7 @@ void Application::startShortcuts() { + + void Application::RegisterUrlScheme() { + base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{ +- .executable = cExeDir() + cExeName(), ++ .executable = qsl("kotatogram-desktop"), + .arguments = qsl("-workdir \"%1\"").arg(cWorkingDir()), + .protocol = qsl("tg"), + .protocolName = qsl("Telegram Link"), +diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp +index 26168baa7..00d2525a0 100644 +--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp ++++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp +@@ -303,19 +303,11 @@ bool GenerateDesktopFile( + + QFile target(targetFile); + if (target.open(QIODevice::WriteOnly)) { +- fileText = fileText.replace( +- QRegularExpression( +- qsl("^TryExec=.*$"), +- QRegularExpression::MultilineOption), +- qsl("TryExec=%1").arg( +- QString(cExeDir() + cExeName()).replace('\\', "\\\\"))); +- + fileText = fileText.replace( + QRegularExpression( + qsl("^Exec=kotatogram-desktop(.*)$"), + QRegularExpression::MultilineOption), +- qsl("Exec=%1 -workdir %2\\1").arg( +- EscapeShellInLauncher(cExeDir() + cExeName()), ++ qsl("Exec=kotatogram-desktop -workdir %1\\1").arg( + EscapeShellInLauncher(cWorkingDir()))); + + fileText = fileText.replace( diff --git a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix index 757fda464fee..e6a2f0f9501d 100644 --- a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix +++ b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/tg_owt.nix @@ -9,26 +9,35 @@ , openssl , libopus , ffmpeg_4 -, alsa-lib -, libpulseaudio , protobuf -, xorg +, openh264 +, usrsctp +, libvpx +, libX11 , libXtst +, libXcomposite +, libXdamage +, libXext +, libXrender +, libXrandr +, libXi +, glib +, abseil-cpp +, pipewire +, mesa +, libglvnd +, libepoxy }: -let - rev = "2d804d2c9c5d05324c8ab22f2e6ff8306521b3c3"; - sha256 = "0kz0i381iwsgcc3yzsq7njx3gkqja4bb9fsgc24vhg0md540qhyn"; - -in stdenv.mkDerivation { pname = "tg_owt"; - version = "git-${rev}"; + version = "unstable-2022-02-26"; src = fetchFromGitHub { owner = "desktop-app"; repo = "tg_owt"; - inherit rev sha256; + rev = "a264028ec71d9096e0aa629113c49c25db89d260"; + sha256 = "sha256-JR+M+4w0QsQLfIunZ/7W+5Knn+gX+RR3DBrpOz7q44I="; fetchSubmodules = true; }; @@ -41,16 +50,34 @@ stdenv.mkDerivation { openssl libopus ffmpeg_4 - alsa-lib - libpulseaudio protobuf - xorg.libX11 + openh264 + usrsctp + libvpx + libX11 libXtst + libXcomposite + libXdamage + libXext + libXrender + libXrandr + libXi + glib + abseil-cpp + pipewire + mesa + libepoxy + libglvnd ]; - cmakeFlags = [ - # Building as a shared library isn't officially supported and currently broken: - "-DBUILD_SHARED_LIBS=OFF" + enableParallelBuilding = true; + + propagatedBuildInputs = [ + # Required for linking downstream binaries. + abseil-cpp + openh264 + usrsctp + libvpx ]; meta.license = lib.licenses.bsd3; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fdcb8c1817a1..26d1a21eecc7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26761,7 +26761,20 @@ with pkgs; kooha = callPackage ../applications/video/kooha { }; - kotatogram-desktop = libsForQt5.callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop { }; + kotatogram-desktop = libsForQt5.callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop { + # C++20 is required, aarch64 has gcc 9 by default + stdenv = if stdenv.isAarch64 then gcc10Stdenv else stdenv; + + # tdesktop has random crashes when jemalloc is built with gcc. + # Apparently, it triggers some bug due to usage of gcc's builtin + # functions like __builtin_ffsl by jemalloc when it's built with gcc. + jemalloc = (jemalloc.override { stdenv = llvmPackages.stdenv; }).overrideAttrs(_: { + # no idea how to fix the tests :( + doCheck = false; + }); + + abseil-cpp = abseil-cpp_202111; + }; kpt = callPackage ../applications/networking/cluster/kpt { };