@@ -1,144 +1,92 @@
11{ stdenv, lib, fetchFromGitHub, fetchgit, pkgconfig, gyp, cmake
2−, qtbase, qtimageformats, qtwayland
3−, breakpad, ffmpeg, openalSoft, openssl, zlib, libexif, lzma, libopus
4−, gtk2, glib, cairo, pango, gdk_pixbuf, atk, libappindicator-gtk2
5−, libwebp, libunity, dee, libdbusmenu-glib, libva-full, wayland
6−, xcbutilrenderutil, icu, libSM, libICE, libproxy, libvdpau
7−
8−, libxcb, xcbutilwm, xcbutilimage, xcbutilkeysyms, libxkbcommon
9−, libpng, libjpeg, freetype, harfbuzz, pcre16, xproto, libX11
10−, inputproto, sqlite, dbus
2+, qtbase, qtimageformats, makeQtWrapper
3+, breakpad, gtk3, libappindicator-gtk3, dee
4+, ffmpeg, openalSoft, minizip
115}:
126
13−let
14− system-x86_64 = lib.elem stdenv.system lib.platforms.x86_64;
15− packagedQt = "5.6.2";
16− # Hacky: split "1.2.3-4" into "1.2.3" and "4"
17− systemQt = (builtins.parseDrvName qtbase.version).name;
18− qtLibs = [ qtbase qtimageformats qtwayland ];
19−
20−in stdenv.mkDerivation rec {
7+stdenv.mkDerivation rec {
218 name = "telegram-desktop-${version}";
22− version = "1.0.2";
23− qtVersion = lib.replaceStrings ["."] ["_"] packagedQt;
24−
25− src = fetchFromGitHub {
26− owner = "telegramdesktop";
27− repo = "tdesktop";
28− rev = "v${version}";
29− sha256 = "1pakxzs28v794x9mm7pb2m0phkfrwq19shz8a6lfyidb6ng85hy2";
9+ version = "1.0.27";
10+
11+ # Submodules
12+ src = fetchgit {
13+ url = "https://github.com/telegramdesktop/tdesktop";
14+ rev = "refs/tags/v${version}";
15+ sha256 = "05g88g6h2a7f9biliicg81fqssx0y3akd3y5r2q2b5h8q3igqrfc";
3016 };
3117
3218 tgaur = fetchgit {
33− url = "https://aur.archlinux.org/telegram-desktop.git";
34− rev = "957a76f9fb691486341bcf4781ad0ef3d16f6b69";
35− sha256 = "01nrvvq0mrdyvamjgqr4z5aahyd1wrf28jyddpfsnixp2w5kxqj8";
19+ url = "https://aur.archlinux.org/telegram-desktop-systemqt.git";
20+ rev = "b4d169076ed12ec01941a95499774d5caa6fc00e";
21+ sha256 = "0pmm6slabg9xazgs0ffnp8v0hx3vnpdfgymvapwqpm3h9mwk22x9";
3622 };
3723
3824 buildInputs = [
39− breakpad ffmpeg openalSoft openssl zlib libexif lzma libopus
40− gtk2 glib libappindicator-gtk2 libunity cairo pango gdk_pixbuf atk
41− dee libdbusmenu-glib libva-full xcbutilrenderutil icu libproxy
42− libSM libICE
43− # Qt dependencies
44− libxcb xcbutilwm xcbutilimage xcbutilkeysyms libxkbcommon
45− libpng libjpeg freetype harfbuzz pcre16 xproto libX11
46− inputproto sqlite dbus libwebp wayland libvdpau
25+ gtk3 libappindicator-gtk3 dee qtbase qtimageformats ffmpeg openalSoft minizip
4726 ];
4827
49− nativeBuildInputs = [ pkgconfig gyp cmake ];
28+ nativeBuildInputs = [ pkgconfig gyp cmake makeQtWrapper ];
5029
51− patches = [ "${tgaur}/aur-fixes.diff" ];
30+ patches = [ "${tgaur}/aur-build-fixes.patch" ];
5231
5332 enableParallelBuilding = true;
5433
55− qtSrcs = builtins.map (x: x.src) qtLibs;
56− qtNames = builtins.map (x: (builtins.parseDrvName x.name).name) (lib.tail qtLibs);
57− qtPatches = qtbase.patches;
58−
59− buildCommand = ''
60− unpackPhase
61− cd "$sourceRoot"
62−
63− patchPhase
64−
65− sed -i Telegram/gyp/Telegram.gyp \
66− -e 's,/usr/include/breakpad,${breakpad}/include/breakpad,g'
34+ GYP_DEFINES = lib.concatStringsSep "," [
35+ "TDESKTOP_DISABLE_CRASH_REPORTS"
36+ "TDESKTOP_DISABLE_AUTOUPDATE"
37+ "TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME"
38+ ];
6739
40+ NIX_CFLAGS_COMPILE = [
41+ "-DTDESKTOP_DISABLE_AUTOUPDATE"
42+ "-DTDESKTOP_DISABLE_CRASH_REPORTS"
43+ "-DTDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME"
44+ "-I${minizip}/include/minizip"
45+ # See Telegram/gyp/qt.gypi
46+ "-I${qtbase.dev}/mkspecs/linux-g++"
47+ ] ++ lib.concatMap (x: [
48+ "-I${qtbase.dev}/include/${x}"
49+ "-I${qtbase.dev}/include/${x}/${qtbase.version}"
50+ "-I${qtbase.dev}/include/${x}/${qtbase.version}/${x}"
51+ ]) [ "QtCore" "QtGui" ];
52+ CPPFLAGS = NIX_CFLAGS_COMPILE;
53+
54+ preConfigure = ''
6855 sed -i Telegram/gyp/telegram_linux.gypi \
6956 -e 's,/usr,/does-not-exist,g' \
57+ -e 's,appindicator-0.1,appindicator3-0.1,g' \
7058 -e 's,-flto,,g'
7159
7260 sed -i Telegram/gyp/qt.gypi \
73− -e 's,${packagedQt},${systemQt},g'
74−
75− gypFlagsArray=(
76− "-Dlinux_path_qt=$PWD/../qt"
77− "-Dlinux_lib_ssl=-lssl"
78− "-Dlinux_lib_crypto=-lcrypto"
79− "-Dlinux_lib_icu=-licuuc -licutu -licui18n"
80− )
81−
82− export QMAKE=$PWD/../qt/bin/qmake
83− ( mkdir -p ../Libraries
84− cd ../Libraries
85− for i in $qtSrcs; do
86− tar -xaf $i
87− done
88− cd qtbase-*
89− # This patch is often outdated but the fixes doesn't feel very important
90− patch -p1 < ../../$sourceRoot/Telegram/Patches/qtbase_${qtVersion}.diff || true
91− for i in $qtPatches; do
92− patch -p1 < $i
93− done
94− ${qtbase.postPatch}
95− cd ..
96−
97− export configureFlags="-prefix "$PWD/../qt" -release -opensource -confirm-license -system-zlib \
98− -system-libpng -system-libjpeg -system-freetype -system-harfbuzz -system-pcre -system-xcb \
99− -system-xkbcommon-x11 -no-eglfs -no-gtkstyle -static -nomake examples -nomake tests \
100− -no-directfb -system-proxies -openssl-linked -dbus-linked -system-sqlite -verbose \
101− ${lib.optionalString (!system-x86_64) "-no-sse2"} -no-sse3 -no-ssse3 \
102− -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-mips_dsp -no-mips_dspr2"
103− export dontAddPrefix=1
104− export MAKEFLAGS=-j$NIX_BUILD_CORES
105−
106− ( cd qtbase-*
107− configurePhase
108− buildPhase
109− make install
110− )
111− for i in $qtNames; do
112− ( cd $i-*
113− $QMAKE
114− buildPhase
115− make install
116− )
117− done
118− )
119−
120− ( cd Telegram/gyp
121− gyp "''${gypFlagsArray[@]}" --depth=. --generator-output=../.. -Goutput_dir=out Telegram.gyp --format=cmake
122− )
123−
124− ( cd out/Release
125− export ASM=$(type -p gcc)
126− cmake .
127− # For some reason, it can't find stdafx.h -- we need to build dependencies till it fails and then retry.
128− buildPhase || true
129− export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -include stdafx.h"
130− buildPhase
131− )
132−
133− install -Dm755 out/Release/Telegram $out/bin/telegram-desktop
61+ -e "s,/usr/bin/moc,moc,g"
62+ sed -i Telegram/gyp/qt_rcc.gypi \
63+ -e "s,/usr/bin/rcc,rcc,g"
64+
65+ gyp \
66+ -Gconfig=Release \
67+ --depth=Telegram/gyp \
68+ --generator-output=../.. \
69+ -Goutput_dir=out \
70+ --format=cmake \
71+ Telegram/gyp/Telegram.gyp
72+
73+ cd out/Release
74+
75+ NUM=$((`wc -l < CMakeLists.txt` - 2))
76+ sed -i "$NUM r $tgaur/CMakeLists.inj" CMakeLists.txt
77+
78+ export ASM=$(type -p gcc)
79+ '';
80+
81+ installPhase = ''
82+ install -Dm755 Telegram $out/bin/telegram-desktop
13483 mkdir -p $out/share/applications $out/share/kde4/services
13584 sed "s,/usr/bin,$out/bin,g" $tgaur/telegramdesktop.desktop > $out/share/applications/telegramdesktop.desktop
13685 sed "s,/usr/bin,$out/bin,g" $tgaur/tg.protocol > $out/share/kde4/services/tg.protocol
13786 for icon_size in 16 32 48 64 128 256 512; do
138− install -Dm644 "Telegram/Resources/art/icon''${icon_size}.png" "$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps/telegram-desktop.png"
87+ install -Dm644 "../../../Telegram/Resources/art/icon''${icon_size}.png" "$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps/telegram-desktop.png"
13988 done
140−
141− fixupPhase
89+ wrapQtProgram $out/bin/telegram-desktop
14290 '';
14391
14492 meta = with stdenv.lib; {