diff options
author | Mx Kookie <kookie@spacekookie.de> | 2020-10-31 19:35:09 +0100 |
---|---|---|
committer | Mx Kookie <kookie@spacekookie.de> | 2020-10-31 19:35:09 +0100 |
commit | c4625b175f8200f643fd6e11010932ea44c78433 (patch) | |
tree | bce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop | |
parent | 49f735974dd103039ddc4cb576bb76555164a9e7 (diff) | |
parent | d661aa56a8843e991261510c1bb28fdc2f6975ae (diff) |
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie
git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7
git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop')
3 files changed, 299 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix b/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix new file mode 100644 index 000000000000..a1a1103b4fd4 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix @@ -0,0 +1,114 @@ +{ mkDerivation, lib, fetchurl, callPackage +, pkgconfig, cmake, ninja, python3, wrapGAppsHook, wrapQtAppsHook +, qtbase, qtimageformats, gtk3, libsForQt5, enchant2, lz4, xxHash +, dee, ffmpeg, openalSoft, minizip, libopus, alsaLib, libpulseaudio, range-v3 +, tl-expected, hunspell +# TODO: Shouldn't be required: +, pcre, xorg, utillinux, libselinux, libsepol, epoxy, at-spi2-core, libXtst +, xdg_utils +}: + +with lib; + +# Main reference: +# - This package was originally based on the Arch package but all patches are now upstreamed: +# https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/telegram-desktop +# Other references that could be useful: +# - https://git.alpinelinux.org/aports/tree/testing/telegram-desktop/APKBUILD +# - https://github.com/void-linux/void-packages/blob/master/srcpkgs/telegram-desktop/template + +let + tg_owt = callPackage ./tg_owt.nix {}; + +in mkDerivation rec { + pname = "telegram-desktop"; + version = "2.4.3"; + + # Telegram-Desktop with submodules + src = fetchurl { + url = "https://github.com/telegramdesktop/tdesktop/releases/download/v${version}/tdesktop-${version}-full.tar.gz"; + sha256 = "15a8pnz4wf3464n8dvfzr9ck0vmhlx16ya1y889y3crjagm4ipjn"; + }; + + postPatch = '' + substituteInPlace Telegram/lib_spellcheck/spellcheck/platform/linux/linux_enchant.cpp \ + --replace '"libenchant-2.so.2"' '"${enchant2}/lib/libenchant-2.so.2"' + substituteInPlace Telegram/CMakeLists.txt \ + --replace '"''${TDESKTOP_LAUNCHER_BASENAME}.appdata.xml"' '"''${TDESKTOP_LAUNCHER_BASENAME}.metainfo.xml"' + ''; + + # We want to run wrapProgram manually (with additional parameters) + dontWrapGApps = true; + dontWrapQtApps = true; + + nativeBuildInputs = [ pkgconfig cmake ninja python3 wrapGAppsHook wrapQtAppsHook ]; + + buildInputs = [ + qtbase qtimageformats gtk3 libsForQt5.libdbusmenu enchant2 lz4 xxHash + dee ffmpeg openalSoft minizip libopus alsaLib libpulseaudio range-v3 + tl-expected hunspell + tg_owt + # TODO: Shouldn't be required: + pcre xorg.libpthreadstubs xorg.libXdmcp utillinux libselinux libsepol epoxy at-spi2-core libXtst + ]; + + enableParallelBuilding = true; + + cmakeFlags = [ + "-Ddisable_autoupdate=ON" + # We're allowed to used the API ID of the Snap package: + "-DTDESKTOP_API_ID=611335" + "-DTDESKTOP_API_HASH=d524b414d21f4d37f08684c1df41ac9c" + #"-DDESKTOP_APP_SPECIAL_TARGET=\"\"" # TODO: Error when set to "": Bad special target '""' + "-DTDESKTOP_LAUNCHER_BASENAME=telegramdesktop" # Note: This is the default + ]; + + # Note: The following packages could be packaged system-wide, but it's + # probably best to use the bundled ones from tdesktop (Arch does this too): + # rlottie: + # - CMake flag: "-DTDESKTOP_USE_PACKAGED_TGVOIP=ON" + # - Sources (problem: there are no stable releases!): + # - desktop-app (tdesktop): https://github.com/desktop-app/rlottie + # - upstream: https://github.com/Samsung/rlottie + # libtgvoip: + # - CMake flag: "-DDESKTOP_APP_USE_PACKAGED_RLOTTIE=ON" + # - Sources (problem: the stable releases might be too old!): + # - tdesktop: https://github.com/telegramdesktop/libtgvoip + # - upstream: https://github.com/grishka/libtgvoip + # Both of these packages are included in this PR (kotatogram-desktop): + # https://github.com/NixOS/nixpkgs/pull/75210 + # TODO: Package mapbox-variant + + postFixup = '' + # Nuke refs to `tg_owt` which is introduced by `__FILE__` in headers. + sed -E "s|($NIX_STORE/)[a-z0-9]{32}(-${tg_owt.name})|\1eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\2|g" \ + --in-place $out/bin/telegram-desktop + + # This is necessary to run Telegram in a pure environment. + # We also use gappsWrapperArgs from wrapGAppsHook. + wrapProgram $out/bin/telegram-desktop \ + "''${gappsWrapperArgs[@]}" \ + "''${qtWrapperArgs[@]}" \ + --prefix PATH : ${xdg_utils}/bin \ + --set XDG_RUNTIME_DIR "XDG-RUNTIME-DIR" + sed -i $out/bin/telegram-desktop \ + -e "s,'XDG-RUNTIME-DIR',\"\''${XDG_RUNTIME_DIR:-/run/user/\$(id --user)}\"," + ''; + + passthru = { + inherit tg_owt; + }; + + meta = { + description = "Telegram Desktop messaging app"; + longDescription = '' + Desktop client for the Telegram messenger, based on the Telegram API and + the MTProto secure protocol. + ''; + license = licenses.gpl3; + platforms = platforms.linux; + homepage = "https://desktop.telegram.org/"; + changelog = "https://github.com/telegramdesktop/tdesktop/releases/tag/v{version}"; + maintainers = with maintainers; [ primeos abbradar ]; + }; +} diff --git a/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt-install.patch b/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt-install.patch new file mode 100644 index 000000000000..bc8a23eb31e5 --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt-install.patch @@ -0,0 +1,159 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6fbc0da..6cbff3c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1856,3 +1856,41 @@ configure_file( + "${CMAKE_CURRENT_BINARY_DIR}/tg_owtConfig.cmake" + COPYONLY + ) ++ ++install( ++TARGETS ++ tg_owt ++ libabsl ++ libopenh264 ++ libpffft ++ librnnoise ++ libsrtp ++ libusrsctp ++ libvpx ++ ${vpx_export} ++ libwebrtcbuild ++ libyuv ++ ${platform_export} ++EXPORT tg_owtTargets ++RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++) ++ ++install( ++ DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/src/ ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++ FILES_MATCHING PATTERN "*.h" ++) ++ ++install( ++ EXPORT tg_owtTargets ++ NAMESPACE tg_owt:: ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/tg_owt ++) ++ ++install( ++ FILES ${CMAKE_CURRENT_BINARY_DIR}/tg_owtConfig.cmake ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/tg_owt ++) +diff --git a/cmake/libabsl.cmake b/cmake/libabsl.cmake +index 2fb3b8c..4a4f85b 100644 +--- a/cmake/libabsl.cmake ++++ b/cmake/libabsl.cmake +@@ -123,5 +123,6 @@ PRIVATE + + target_include_directories(libabsl + PUBLIC +- ${libabsl_loc} ++ $<BUILD_INTERFACE:${libabsl_loc}> ++ $<INSTALL_INTERFACE:include/third_party/abseil-cpp> + ) +diff --git a/cmake/libpffft.cmake b/cmake/libpffft.cmake +index a6ceb3e..435d3a3 100644 +--- a/cmake/libpffft.cmake ++++ b/cmake/libpffft.cmake +@@ -24,5 +24,6 @@ endif() + + target_include_directories(libpffft + PUBLIC +- ${libpffft_loc} ++ $<BUILD_INTERFACE:${libpffft_loc}> ++ $<INSTALL_INTERFACE:include/third_party/pffft/src> + ) +diff --git a/cmake/libsrtp.cmake b/cmake/libsrtp.cmake +index 57c54b5..26b3466 100644 +--- a/cmake/libsrtp.cmake ++++ b/cmake/libsrtp.cmake +@@ -30,6 +30,8 @@ PRIVATE + + target_include_directories(libsrtp + PUBLIC +- ${libsrtp_loc}/include +- ${libsrtp_loc}/crypto/include ++ $<BUILD_INTERFACE:${libsrtp_loc}/include> ++ $<BUILD_INTERFACE:${libsrtp_loc}/crypto/include> ++ $<INSTALL_INTERFACE:include/third_party/libsrtp/include> ++ $<INSTALL_INTERFACE:include/third_party/libsrtp/crypto/include> + ) +diff --git a/cmake/libusrsctp.cmake b/cmake/libusrsctp.cmake +index caa0529..38d2ef6 100644 +--- a/cmake/libusrsctp.cmake ++++ b/cmake/libusrsctp.cmake +@@ -67,6 +67,8 @@ endif() + + target_include_directories(libusrsctp + PUBLIC +- ${third_party_loc}/usrsctp/usrsctplib +- ${libusrsctp_loc} ++ $<BUILD_INTERFACE:${third_party_loc}/usrsctp/usrsctplib> ++ $<BUILD_INTERFACE:${libusrsctp_loc}> ++ $<INSTALL_INTERFACE:include/third_party/usrsctp/usrsctplib/usrsctplib> ++ $<INSTALL_INTERFACE:include/third_party/usrsctp/usrsctplib> + ) +diff --git a/cmake/libvpx.cmake b/cmake/libvpx.cmake +index e192e7e..78cf25b 100644 +--- a/cmake/libvpx.cmake ++++ b/cmake/libvpx.cmake +@@ -68,6 +68,11 @@ else() + set(ASM_SUFFIX ".asm.S") + endif() + ++foreach(dir ${include_directories}) ++ string(REPLACE ${libvpx_loc} include/third_party/libvpx install_include_dir ${dir}) ++ list(APPEND install_include_directories ${install_include_dir}) ++endforeach() ++ + function(add_sublibrary postfix) + add_library(libvpx_${postfix} OBJECT) + init_feature_target(libvpx_${postfix} ${postfix}) +@@ -75,6 +80,8 @@ function(add_sublibrary postfix) + target_include_directories(libvpx_${postfix} + PRIVATE + ${include_directories} ++ "$<BUILD_INTERFACE:${include_directories}>" ++ "$<INSTALL_INTERFACE:${install_include_directories}>" + ) + set(sources_list ${ARGV}) + list(REMOVE_AT sources_list 0) +@@ -725,5 +732,6 @@ endif() + + target_include_directories(libvpx + PUBLIC +- ${include_directories} ++ "$<BUILD_INTERFACE:${include_directories}>" ++ "$<INSTALL_INTERFACE:${install_include_directories}>" + ) +diff --git a/cmake/libwebrtcbuild.cmake b/cmake/libwebrtcbuild.cmake +index c3520b8..9b4b543 100644 +--- a/cmake/libwebrtcbuild.cmake ++++ b/cmake/libwebrtcbuild.cmake +@@ -44,5 +44,6 @@ endif() + + target_include_directories(libwebrtcbuild + INTERFACE +- ${webrtc_loc} ++ $<BUILD_INTERFACE:${webrtc_loc}> ++ $<INSTALL_INTERFACE:include> + ) +diff --git a/cmake/libyuv.cmake b/cmake/libyuv.cmake +index ebfc6f0..18e70ef 100644 +--- a/cmake/libyuv.cmake ++++ b/cmake/libyuv.cmake +@@ -126,7 +126,8 @@ endif() + + target_include_directories(libyuv + PUBLIC +- ${libyuv_loc}/include ++ $<BUILD_INTERFACE:${libyuv_loc}/include> ++ $<INSTALL_INTERFACE:include/third_party/libyuv/include> + ) + + target_compile_definitions(libyuv diff --git a/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt.nix b/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt.nix new file mode 100644 index 000000000000..47e9b6787e3e --- /dev/null +++ b/infra/libkookie/nixpkgs/pkgs/applications/networking/instant-messengers/telegram/tdesktop/tg_owt.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, fetchFromGitHub, cmake, ninja, yasm +, pkg-config, libjpeg, openssl, libopus, ffmpeg, alsaLib, libpulseaudio +}: + +let + rev = "c73a4718cbff7048373a63db32068482e5fd11ef"; + sha256 = "0nr20mvvmmg8ii8f2rljd7iv2szplcfjn40rpy6llkmf705mwr1k"; + +in stdenv.mkDerivation { + pname = "tg_owt"; + version = "git-${rev}"; + + src = fetchFromGitHub { + owner = "desktop-app"; + repo = "tg_owt"; + inherit rev sha256; + }; + + patches = [ ./tg_owt-install.patch ]; + + nativeBuildInputs = [ pkg-config cmake ninja yasm ]; + + buildInputs = [ libjpeg openssl libopus ffmpeg alsaLib libpulseaudio ]; + + meta.license = lib.licenses.bsd3; +} |