2016-03-28 14:46:44 +01:00
|
|
|
{ stdenv, lib, fetchFromGitHub, fetchgit, qtbase, qtimageformats
|
|
|
|
, breakpad, ffmpeg, openalSoft, openssl, zlib, libexif, lzma, libopus
|
|
|
|
, gtk2, glib, cairo, pango, gdk_pixbuf, atk, libappindicator-gtk2
|
2016-05-20 01:44:05 +01:00
|
|
|
, libwebp, libunity, dee, libdbusmenu-glib, libva
|
2016-03-28 14:46:44 +01:00
|
|
|
|
|
|
|
, pkgconfig, libxcb, xcbutilwm, xcbutilimage, xcbutilkeysyms
|
|
|
|
, libxkbcommon, libpng, libjpeg, freetype, harfbuzz, pcre16
|
|
|
|
, xproto, libX11, inputproto, sqlite, dbus
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
system-x86_64 = lib.elem stdenv.system lib.platforms.x86_64;
|
2016-06-09 19:37:24 +01:00
|
|
|
packagedQt = "5.6.0";
|
2016-07-23 07:40:36 +01:00
|
|
|
# Hacky: split "1.2.3-4" into "1.2.3" and "4"
|
|
|
|
systemQt = (builtins.parseDrvName qtbase.version).name;
|
2016-06-27 20:01:44 +01:00
|
|
|
|
2016-03-28 14:46:44 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "telegram-desktop-${version}";
|
2016-06-27 20:01:44 +01:00
|
|
|
version = "0.9.56";
|
2016-06-09 19:37:24 +01:00
|
|
|
qtVersion = lib.replaceStrings ["."] ["_"] packagedQt;
|
2016-03-28 14:46:44 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "telegramdesktop";
|
|
|
|
repo = "tdesktop";
|
|
|
|
rev = "v${version}";
|
2016-06-27 20:01:44 +01:00
|
|
|
sha256 = "000ngg6arfb6mif0hvin099f83q3sn7mw4vfvrikskczblw3a5lc";
|
2016-03-28 14:46:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
tgaur = fetchgit {
|
|
|
|
url = "https://aur.archlinux.org/telegram-desktop.git";
|
2016-04-30 00:59:00 +01:00
|
|
|
rev = "f8907d1ccaf8345c06232238342921213270e3d8";
|
2016-05-25 16:43:15 +01:00
|
|
|
sha256 = "04jh0fsrh4iwg188d20z15qkxv05wa5lpd8h21yxx3jxqljpdkws";
|
2016-03-28 14:46:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
breakpad ffmpeg openalSoft openssl zlib libexif lzma libopus
|
|
|
|
gtk2 glib libappindicator-gtk2 libunity cairo pango gdk_pixbuf atk
|
2016-05-20 01:44:05 +01:00
|
|
|
dee libdbusmenu-glib libva
|
2016-03-28 14:46:44 +01:00
|
|
|
# Qt dependencies
|
|
|
|
libxcb xcbutilwm xcbutilimage xcbutilkeysyms libxkbcommon
|
|
|
|
libpng libjpeg freetype harfbuzz pcre16 xproto libX11
|
2016-05-20 01:44:05 +01:00
|
|
|
inputproto sqlite dbus libwebp
|
2016-03-28 14:46:44 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
qmakeFlags = [
|
|
|
|
"CONFIG+=release"
|
|
|
|
"DEFINES+=TDESKTOP_DISABLE_AUTOUPDATE"
|
|
|
|
"DEFINES+=TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME"
|
2016-04-16 18:34:51 +01:00
|
|
|
"INCLUDEPATH+=${gtk2.dev}/include/gtk-2.0"
|
2016-04-16 17:57:59 +01:00
|
|
|
"INCLUDEPATH+=${glib.dev}/include/glib-2.0"
|
2016-04-14 02:11:58 +01:00
|
|
|
"INCLUDEPATH+=${glib.out}/lib/glib-2.0/include"
|
2016-04-16 17:46:29 +01:00
|
|
|
"INCLUDEPATH+=${cairo.dev}/include/cairo"
|
2016-04-16 18:45:20 +01:00
|
|
|
"INCLUDEPATH+=${pango.dev}/include/pango-1.0"
|
2016-04-14 02:11:58 +01:00
|
|
|
"INCLUDEPATH+=${gtk2.out}/lib/gtk-2.0/include"
|
2016-04-16 17:53:37 +01:00
|
|
|
"INCLUDEPATH+=${gdk_pixbuf.dev}/include/gdk-pixbuf-2.0"
|
2016-04-16 17:42:06 +01:00
|
|
|
"INCLUDEPATH+=${atk.dev}/include/atk-1.0"
|
2016-03-28 14:46:44 +01:00
|
|
|
"INCLUDEPATH+=${libappindicator-gtk2}/include/libappindicator-0.1"
|
|
|
|
"INCLUDEPATH+=${libunity}/include/unity"
|
|
|
|
"INCLUDEPATH+=${dee}/include/dee-1.0"
|
|
|
|
"INCLUDEPATH+=${libdbusmenu-glib}/include/libdbusmenu-glib-0.4"
|
|
|
|
"INCLUDEPATH+=${breakpad}/include/breakpad"
|
2016-06-27 20:01:44 +01:00
|
|
|
"QT_TDESKTOP_VERSION=${systemQt}"
|
2016-03-28 14:46:44 +01:00
|
|
|
"LIBS+=-lcrypto"
|
|
|
|
"LIBS+=-lssl"
|
|
|
|
];
|
|
|
|
|
2016-06-09 19:37:24 +01:00
|
|
|
qtSrcs = [ qtbase.src qtimageformats.src ];
|
2016-03-28 14:46:44 +01:00
|
|
|
qtPatches = qtbase.patches;
|
|
|
|
|
2016-04-17 00:36:28 +01:00
|
|
|
buildCommand = ''
|
2016-03-28 14:46:44 +01:00
|
|
|
unpackPhase
|
|
|
|
cd "$sourceRoot"
|
2016-05-20 01:44:05 +01:00
|
|
|
|
2016-03-28 14:46:44 +01:00
|
|
|
patchPhase
|
|
|
|
sed -i 'Telegram/Telegram.pro' \
|
2016-05-20 01:44:05 +01:00
|
|
|
-e 's,CUSTOM_API_ID,,g' \
|
2016-03-28 14:46:44 +01:00
|
|
|
-e 's,/usr,/does-not-exist,g' \
|
|
|
|
-e '/LIBS += .*libxkbcommon.a/d' \
|
2016-05-20 01:44:05 +01:00
|
|
|
-e 's,LIBS += .*libz.a,LIBS += -lz,' \
|
|
|
|
-e 's,LIBS += .*libbreakpad_client.a,LIBS += ${breakpad}/lib/libbreakpad_client.a,' \
|
|
|
|
-e 's, -flto,,g' \
|
2016-06-27 20:01:44 +01:00
|
|
|
-e 's, -static-libstdc++,,g'
|
|
|
|
|
|
|
|
export qmakeFlags="$qmakeFlags QT_TDESKTOP_PATH=$PWD/../qt"
|
2016-04-30 00:59:00 +01:00
|
|
|
|
2016-05-20 01:44:05 +01:00
|
|
|
export QMAKE=$PWD/../qt/bin/qmake
|
2016-03-28 14:46:44 +01:00
|
|
|
( mkdir -p ../Libraries
|
|
|
|
cd ../Libraries
|
|
|
|
for i in $qtSrcs; do
|
|
|
|
tar -xaf $i
|
|
|
|
done
|
2016-06-09 19:37:24 +01:00
|
|
|
cd qtbase-*
|
2016-06-27 20:01:44 +01:00
|
|
|
# This patch is outdated but the fixes doesn't feel very important
|
|
|
|
patch -p1 < ../../$sourceRoot/Telegram/Patches/qtbase_${qtVersion}.diff || true
|
2016-03-28 14:46:44 +01:00
|
|
|
for i in $qtPatches; do
|
|
|
|
patch -p1 < $i
|
|
|
|
done
|
|
|
|
${qtbase.postPatch}
|
2016-06-09 19:37:24 +01:00
|
|
|
cd ..
|
2016-03-28 14:46:44 +01:00
|
|
|
|
2016-06-09 19:37:24 +01:00
|
|
|
export configureFlags="-prefix "$PWD/../qt" -release -opensource -confirm-license -system-zlib \
|
2016-03-28 14:46:44 +01:00
|
|
|
-system-libpng -system-libjpeg -system-freetype -system-harfbuzz -system-pcre -system-xcb \
|
|
|
|
-system-xkbcommon-x11 -no-opengl -static -nomake examples -nomake tests \
|
|
|
|
-openssl-linked -dbus-linked -system-sqlite -verbose \
|
|
|
|
${lib.optionalString (!system-x86_64) "-no-sse2"} -no-sse3 -no-ssse3 \
|
|
|
|
-no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-mips_dsp -no-mips_dspr2"
|
|
|
|
export dontAddPrefix=1
|
2016-05-20 01:44:05 +01:00
|
|
|
export MAKEFLAGS=-j$NIX_BUILD_CORES
|
2016-03-28 14:46:44 +01:00
|
|
|
|
2016-06-09 19:37:24 +01:00
|
|
|
( cd qtbase-*
|
2016-03-28 14:46:44 +01:00
|
|
|
configurePhase
|
2016-05-20 01:44:05 +01:00
|
|
|
buildPhase
|
|
|
|
make install
|
|
|
|
)
|
|
|
|
|
2016-06-09 19:37:24 +01:00
|
|
|
( cd qtimageformats-*
|
2016-05-20 01:44:05 +01:00
|
|
|
$QMAKE
|
|
|
|
buildPhase
|
|
|
|
make install
|
2016-03-28 14:46:44 +01:00
|
|
|
)
|
2016-05-20 01:44:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
( mkdir -p Linux/obj/codegen_style/Debug
|
|
|
|
cd Linux/obj/codegen_style/Debug
|
2016-06-27 20:01:44 +01:00
|
|
|
$QMAKE $qmakeFlags ../../../../Telegram/build/qmake/codegen_style/codegen_style.pro
|
2016-05-20 01:44:05 +01:00
|
|
|
buildPhase
|
|
|
|
)
|
|
|
|
( mkdir -p Linux/obj/codegen_numbers/Debug
|
|
|
|
cd Linux/obj/codegen_numbers/Debug
|
2016-06-27 20:01:44 +01:00
|
|
|
$QMAKE $qmakeFlags ../../../../Telegram/build/qmake/codegen_numbers/codegen_numbers.pro
|
2016-05-20 01:44:05 +01:00
|
|
|
buildPhase
|
|
|
|
)
|
|
|
|
( mkdir -p Linux/DebugIntermediateLang
|
|
|
|
cd Linux/DebugIntermediateLang
|
2016-06-27 20:01:44 +01:00
|
|
|
$QMAKE $qmakeFlags ../../Telegram/MetaLang.pro
|
2016-03-28 14:46:44 +01:00
|
|
|
buildPhase
|
|
|
|
)
|
|
|
|
|
|
|
|
( mkdir -p Linux/ReleaseIntermediate
|
|
|
|
cd Linux/ReleaseIntermediate
|
2016-05-20 01:44:05 +01:00
|
|
|
$QMAKE $qmakeFlags ../../Telegram/Telegram.pro
|
2016-03-28 14:46:44 +01:00
|
|
|
pattern="^PRE_TARGETDEPS +="
|
|
|
|
grep "$pattern" "../../Telegram/Telegram.pro" | sed "s/$pattern//g" | xargs make
|
|
|
|
buildPhase
|
|
|
|
)
|
|
|
|
|
|
|
|
install -Dm755 Linux/Release/Telegram $out/bin/telegram-desktop
|
|
|
|
mkdir -p $out/share/applications $out/share/kde4/services
|
|
|
|
sed "s,/usr/bin,$out/bin,g" $tgaur/telegramdesktop.desktop > $out/share/applications/telegramdesktop.desktop
|
|
|
|
sed "s,/usr/bin,$out/bin,g" $tgaur/tg.protocol > $out/share/kde4/services/tg.protocol
|
|
|
|
for icon_size in 16 32 48 64 128 256 512; do
|
2016-04-30 00:59:00 +01:00
|
|
|
install -Dm644 "Telegram/Resources/art/icon''${icon_size}.png" "$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps/telegram-desktop.png"
|
2016-03-28 14:46:44 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
fixupPhase
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Telegram Desktop messaging app";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
homepage = "https://desktop.telegram.org/";
|
2016-05-25 16:43:15 +01:00
|
|
|
maintainers = with maintainers; [ abbradar garbas ];
|
2016-03-28 14:46:44 +01:00
|
|
|
};
|
|
|
|
}
|