Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d5f9a98e0610
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f430ac79b87b
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jan 18, 2020

  1. tdesktop: 1.8.15 -> 1.9.3

    The GYP build is now deprecated [0].
    This results in a large number of changes and many custom Nix patches
    aren't required anymore (and probably haven't been required for quite
    some time now, the derivation got a bit outdated...).
    
    A lot of the changes in this commit are based on the changes of the
    Arch package [1][2] (which our package is based upon).
    
    Rough overview of the changes:
    - gcc9 -> ninja (optional but let's follow Arch here)
    - Dropped GYP, only CMake now
      - But: Python is still required
    - fetchFromGitHub -> fetchurl (optional?)
    - Apply all Arch patches and remove old patches
      - Requires one new patch for range-v3
    - New dependencies: enchant2, lz4, xxHash
      - TODO: Plus a few new dependencies that shouldn't be required
    - Cleanup: Irrelevant flags (e.g. GYP_DEFINES) and patches (e.g. sed)
      - Simplifies quite a few things :)
    - Some additional documentation and TODOs
    
    Co-Authored-By: Jan Tojnar <jtojnar@gmail.com>
    
    [0]: telegramdesktop/tdesktop#7001
    [1]: https://git.archlinux.org/svntogit/community.git/commit/?id=23eff2b1ef7435441e93120618ca899f0b0e7e61
    [2]: https://git.archlinux.org/svntogit/community.git/commit/?id=6a19e949724b2e2bfcdcf2081111ecd46108e449
    primeos committed Jan 18, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Ma27 Maximilian Bosch
    Copy the full SHA
    1835ac1 View commit details
  2. Merge pull request #77453 from primeos/tdesktop

    tdesktop: 1.8.15 -> 1.9.3
    primeos authored Jan 18, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Ma27 Maximilian Bosch
    Copy the full SHA
    f430ac7 View commit details
Showing with 49 additions and 89 deletions.
  1. +49 −89 pkgs/applications/networking/instant-messengers/telegram/tdesktop/default.nix
Original file line number Diff line number Diff line change
@@ -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
'';