Merge pull request #77453 from primeos/tdesktop

tdesktop: 1.8.15 -> 1.9.3
This commit is contained in:
Michael Weiss 2020-01-19 00:01:48 +01:00 committed by GitHub
commit f430ac79b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,79 +1,74 @@
{ mkDerivation, lib, fetchFromGitHub, fetchsvn, fetchpatch
, pkgconfig, pythonPackages, cmake, wrapGAppsHook, wrapQtAppsHook, gcc9
, qtbase, qtimageformats, gtk3, libappindicator-gtk3, libnotify, xdg_utils
{ mkDerivation, lib, fetchurl, fetchsvn
, pkgconfig, cmake, ninja, python3, wrapGAppsHook, wrapQtAppsHook
, qtbase, qtimageformats, gtk3, libappindicator-gtk3, enchant2, lz4, xxHash
, dee, ffmpeg_4, openalSoft, minizip, libopus, alsaLib, libpulseaudio, range-v3
# TODO: Shouldn't be required:
, pcre, xorg, utillinux, libselinux, libsepol, epoxy, at-spi2-core, libXtst
, xdg_utils
}:
with lib;
# Main reference:
# - This package is based on the Arch package:
# https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/telegram-desktop
# Other references that could be useful (but we should try to stick to Arch):
# - https://git.alpinelinux.org/aports/tree/testing/telegram-desktop/APKBUILD
# - https://github.com/void-linux/void-packages/blob/master/srcpkgs/telegram-desktop/template
mkDerivation rec {
pname = "telegram-desktop";
version = "1.8.15";
version = "1.9.3";
# Note: Due to our strong dependency on the Arch patches it's probably best
# to also wait for the Arch update (especially if the patches don't apply).
# Telegram-Desktop with submodules
src = fetchFromGitHub {
owner = "telegramdesktop";
repo = "tdesktop";
rev = "v${version}";
sha256 = "03173y2nlkf757llgpia8p2dkkwsjra7b6qm5nhmkcwcm8kmsvyy";
fetchSubmodules = true;
src = fetchurl {
url = "https://github.com/telegramdesktop/tdesktop/releases/download/v${version}/tdesktop-${version}-full.tar.gz";
sha256 = "1fx7v7j7iw4iywdbl89c5f1y74via61a0k20zrgjv5a0j4v6g76a";
};
# Arch patches (svn export telegram-desktop/trunk)
archPatches = fetchsvn {
url = "svn://svn.archlinux.org/community/telegram-desktop/trunk";
# svn log svn://svn.archlinux.org/community/telegram-desktop/trunk
rev = "512849";
sha256 = "1hl7znvv6qr4cwpkj8wlplpa63i1lhk2iax7hb4l1s1a4mijx9ls";
};
privateHeadersPatch = fetchpatch {
url = "https://github.com/telegramdesktop/tdesktop/commit/b9d3ba621eb8af638af46c6b3cfd7a8330bf0dd5.patch";
sha256 = "1s5xvcp9dk0jfywssk8xfcsh7bk5xxif8xqnba0413lfx5rgvs5v";
rev = "549803";
sha256 = "1py2a25wgpvx0n4kz383fj0jav1qdm8wqx5bdaygg6296r294czj";
};
# Note: It would be best if someone could get as many patches upstream as
# possible (we currently depend a lot on custom patches...).
patches = [
"${archPatches}/tdesktop.patch"
"${archPatches}/no-gtk2.patch"
"${archPatches}/Revert-Disable-DemiBold-fallback-for-Semibold.patch"
"${archPatches}/tdesktop_lottie_animation_qtdebug.patch"
# "${archPatches}/Revert-Change-some-private-header-includes.patch"
# "${archPatches}/Use-system-wide-font.patch"
"${archPatches}/0001-Dynamic-linking-system-libs.patch"
"${archPatches}/0002-Dynamic-linking-system-qt.patch"
"${archPatches}/0004-gtk3.patch"
"${archPatches}/0005-Use-system-wide-fonts.patch"
"${archPatches}/0006-Revert-Disable-DemiBold-fallback-for-Semibold.patch"
];
postPatch = ''
substituteInPlace Telegram/SourceFiles/platform/linux/linux_libs.cpp \
--replace '"appindicator3"' '"${libappindicator-gtk3}/lib/libappindicator3.so"'
substituteInPlace Telegram/SourceFiles/platform/linux/linux_libnotify.cpp \
--replace '"notify"' '"${libnotify}/lib/libnotify.so"'
substituteInPlace cmake/external/ranges/CMakeLists.txt \
--replace "/usr/include" "${range-v3}/include"
'';
# We want to run wrapProgram manually (with additional parameters)
dontWrapGApps = true;
dontWrapQtApps = true;
nativeBuildInputs = [ pkgconfig pythonPackages.gyp cmake wrapGAppsHook wrapQtAppsHook gcc9 ];
nativeBuildInputs = [ pkgconfig cmake ninja python3 wrapGAppsHook wrapQtAppsHook ];
buildInputs = [
qtbase qtimageformats gtk3 libappindicator-gtk3
qtbase qtimageformats gtk3 libappindicator-gtk3 enchant2 lz4 xxHash
dee ffmpeg_4 openalSoft minizip libopus alsaLib libpulseaudio range-v3
# TODO: Shouldn't be required:
pcre xorg.libpthreadstubs xorg.libXdmcp utillinux libselinux libsepol epoxy at-spi2-core libXtst
];
enableParallelBuilding = true;
GYP_DEFINES = concatStringsSep "," [
"TDESKTOP_DISABLE_CRASH_REPORTS"
"TDESKTOP_DISABLE_AUTOUPDATE"
"TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME"
];
NIX_CFLAGS_COMPILE = [
"-DTDESKTOP_DISABLE_CRASH_REPORTS"
"-DTDESKTOP_DISABLE_AUTOUPDATE"
"-DTDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME"
"-I${minizip}/include/minizip"
# See Telegram/gyp/qt.gypi
"-I${getDev qtbase}/mkspecs/linux-g++"
@ -87,64 +82,29 @@ mkDerivation rec {
]) [ "QtCore" "QtGui" "QtDBus" ];
CPPFLAGS = NIX_CFLAGS_COMPILE;
preConfigure = ''
# Patches to revert:
patch -R -Np1 -i "${privateHeadersPatch}"
# Patches to apply:
pushd "Telegram/ThirdParty/libtgvoip"
patch -Np1 -i "${archPatches}/libtgvoip.patch"
popd
# disable static-qt for rlottie
sed "/RLOTTIE_WITH_STATIC_QT/d" -i "Telegram/gyp/lib_rlottie.gyp"
sed -i Telegram/gyp/telegram/linux.gypi \
-e 's,/usr,/does-not-exist,g' \
-e 's,appindicator-0.1,appindicator3-0.1,g' \
-e 's,-flto,,g'
sed -i Telegram/gyp/modules/qt.gypi \
-e "s,/usr/include/qt/QtCore/,${qtbase.dev}/include/QtCore/,g" \
-e 's,\d+",\d+" | head -n1,g'
sed -i Telegram/gyp/modules/qt_moc.gypi \
-e "s,/usr/bin/moc,moc,g"
sed -i Telegram/gyp/modules/qt_rcc.gypi \
-e "s,/usr/bin/rcc,rcc,g"
# Build system assumes x86, but it works fine on non-x86 if we patch this one flag out
sed -i Telegram/ThirdParty/libtgvoip/libtgvoip.gyp \
-e "/-msse2/d"
gyp \
-Dapi_id=17349 \
-Dapi_hash=344583e45741c457fe1862106095a5eb \
-Dbuild_defines=${GYP_DEFINES} \
-Gconfig=Release \
--depth=Telegram/gyp \
--generator-output=../.. \
-Goutput_dir=out \
--format=cmake \
Telegram/gyp/Telegram.gyp
cd out/Release
NUM=$((`wc -l < CMakeLists.txt` - 2))
sed -i "$NUM r $archPatches/CMakeLists.inj" CMakeLists.txt
export ASM=$(type -p gcc)
'';
cmakeFlags = [ "-UTDESKTOP_OFFICIAL_TARGET" ];
cmakeFlags = [
#"-DTDESKTOP_API_TEST=ON" # TODO: Officiall API credentials for Nixpkgs
"-DTDESKTOP_API_ID=17349" # See: https://github.com/NixOS/nixpkgs/issues/55271
"-DTDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb"
"-DDESKTOP_APP_USE_GLIBC_WRAPS=OFF"
"-DDESKTOP_APP_USE_SYSTEM_LIBS=ON"
"-DDESKTOP_APP_DISABLE_CRASH_REPORTS=ON"
"-Ddisable_autoupdate=ON"
"-DTDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME=ON"
"-DTDESKTOP_DISABLE_DESKTOP_FILE_GENERATION=ON"
#"-DDESKTOP_APP_SPECIAL_TARGET=\"\"" # TODO: Error when set to "": Bad special target '""'
];
installPhase = ''
install -Dm755 Telegram $out/bin/telegram-desktop
install -Dm755 bin/Telegram $out/bin/telegram-desktop
mkdir -p $out/share/{kservices5,applications,metainfo}
sed "s,/usr/bin,$out/bin,g" "../lib/xdg/tg.protocol" > "$out/share/kservices5/tg.protocol"
install -m444 "../lib/xdg/telegramdesktop.desktop" "$out/share/applications/telegram-desktop.desktop"
install -m644 "../lib/xdg/telegramdesktop.appdata.xml" "$out/share/metainfo/telegramdesktop.metainfo.xml"
mkdir -p $out/share/applications $out/share/kde4/services
install -m444 "$src/lib/xdg/telegramdesktop.desktop" "$out/share/applications/telegram-desktop.desktop"
sed "s,/usr/bin,$out/bin,g" $archPatches/tg.protocol > $out/share/kde4/services/tg.protocol
for icon_size in 16 32 48 64 128 256 512; do
install -Dm644 "../../../Telegram/Resources/art/icon''${icon_size}.png" "$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps/telegram.png"
install -Dm644 "../Telegram/Resources/art/icon''${icon_size}.png" "$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps/telegram.png"
done
'';