tdesktopPackages.*: Remove the attributes in favour of tdesktop

This is a refactoring of "tdesktop", i.e. the resulting derivation isn't
affected by this commit (only the tdesktopPackages.* attributes are
removed).

I decided to remove the attributes "tdesktopPackages.*" as I don't
maintain the preview version anymore. There are regular stable releases
and we depend on the patches from Arch Linux which only track the stable
version as well, i.e. I would have to maintain our own patches, which
would either require an additional repository or "bloat" Nixpkgs (apart
from the fact that it would be unnecessarily time-consuming).
This commit is contained in:
Michael Weiss 2019-07-30 16:57:46 +02:00
parent 609ce6a23d
commit 1d102b90e6
No known key found for this signature in database
GPG Key ID: 5BE487C4D4771D83
3 changed files with 164 additions and 178 deletions

View File

@ -1,18 +1,159 @@
{ qt5 }:
{ mkDerivation, lib, fetchFromGitHub, fetchsvn
, pkgconfig, pythonPackages, cmake, wrapGAppsHook, wrapQtAppsHook, gcc8
, qtbase, qtimageformats, gtk3, libappindicator-gtk3, libnotify, xdg_utils
, dee, ffmpeg, openalSoft, minizip, libopus, alsaLib, libpulseaudio, range-v3
}:
let
mkTelegram = args: qt5.callPackage (import ./generic.nix args) { };
stableVersion = {
stable = true;
version = "1.7.14";
sha256Hash = "1bw804a9kffmn23wv0570wihbvfm7jy9cqmxlv196f4j7bw7zkv3";
# svn log svn://svn.archlinux.org/community/telegram-desktop/trunk
archPatchesRevision = "487779";
archPatchesHash = "0f09hvimb66xqksb2v0zc4ryshx7y7z0rafzjd99x37rpib9f3kq";
with lib;
mkDerivation rec {
name = "telegram-desktop-${version}";
version = "1.7.14";
# Telegram-Desktop with submodules
src = fetchFromGitHub {
owner = "telegramdesktop";
repo = "tdesktop";
rev = "v${version}";
sha256 = "1bw804a9kffmn23wv0570wihbvfm7jy9cqmxlv196f4j7bw7zkv3";
fetchSubmodules = true;
};
# 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 = "487779";
sha256 = "0f09hvimb66xqksb2v0zc4ryshx7y7z0rafzjd99x37rpib9f3kq";
};
patches = [
"${archPatches}/tdesktop.patch"
"${archPatches}/no-gtk2.patch"
# "${archPatches}/Use-system-wide-font.patch"
"${archPatches}/tdesktop_lottie_animation_qtdebug.patch"
"${archPatches}/issue6219.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"'
'';
nativeBuildInputs = [ pkgconfig pythonPackages.gyp cmake wrapGAppsHook wrapQtAppsHook gcc8 ];
# We want to run wrapProgram manually (with additional parameters)
dontWrapGApps = true;
dontWrapQtApps = true;
buildInputs = [
qtbase qtimageformats gtk3 libappindicator-gtk3
dee ffmpeg openalSoft minizip libopus alsaLib libpulseaudio range-v3
];
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++"
] ++ concatMap (x: [
"-I${getDev qtbase}/include/${x}"
"-I${getDev qtbase}/include/${x}/${qtbase.version}"
"-I${getDev qtbase}/include/${x}/${qtbase.version}/${x}"
"-I${getDev libopus}/include/opus"
"-I${getDev alsaLib}/include/alsa"
"-I${getDev libpulseaudio}/include/pulse"
]) [ "QtCore" "QtGui" "QtDBus" ];
CPPFLAGS = NIX_CFLAGS_COMPILE;
preConfigure = ''
patch -R -Np1 -i "${archPatches}/demibold.patch"
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/qt.gypi \
-e "s,/usr/include/qt/QtCore/,${qtbase.dev}/include/QtCore/,g" \
-e 's,\d+",\d+" | head -n1,g'
sed -i Telegram/gyp/qt_moc.gypi \
-e "s,/usr/bin/moc,moc,g"
sed -i Telegram/gyp/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" ];
installPhase = ''
install -Dm755 Telegram $out/bin/telegram-desktop
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"
done
'';
postFixup = ''
# 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)}\","
'';
meta = {
description = "Telegram Desktop messaging app";
license = licenses.gpl3;
platforms = platforms.linux;
homepage = https://desktop.telegram.org/;
maintainers = with maintainers; [ primeos abbradar ];
};
in {
stable = mkTelegram stableVersion;
preview = mkTelegram (stableVersion // {
stable = false;
});
}

View File

@ -1,161 +0,0 @@
{ stable, version, sha256Hash, archPatchesRevision, archPatchesHash }:
{ mkDerivation, lib, fetchFromGitHub, fetchsvn
, pkgconfig, pythonPackages, cmake, wrapGAppsHook, wrapQtAppsHook, gcc8
, qtbase, qtimageformats, gtk3, libappindicator-gtk3, libnotify, xdg_utils
, dee, ffmpeg, openalSoft, minizip, libopus, alsaLib, libpulseaudio, range-v3
}:
with lib;
mkDerivation rec {
name = "telegram-desktop-${version}";
inherit version;
# Telegram-Desktop with submodules
src = fetchFromGitHub {
owner = "telegramdesktop";
repo = "tdesktop";
rev = "v${version}";
sha256 = sha256Hash;
fetchSubmodules = true;
};
# Arch patches (svn export telegram-desktop/trunk)
archPatches = fetchsvn {
url = "svn://svn.archlinux.org/community/telegram-desktop/trunk";
rev = archPatchesRevision;
sha256 = archPatchesHash;
};
patches = [
"${archPatches}/tdesktop.patch"
"${archPatches}/no-gtk2.patch"
# "${archPatches}/Use-system-wide-font.patch"
"${archPatches}/tdesktop_lottie_animation_qtdebug.patch"
"${archPatches}/issue6219.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"'
'';
nativeBuildInputs = [ pkgconfig pythonPackages.gyp cmake wrapGAppsHook wrapQtAppsHook gcc8 ];
# We want to run wrapProgram manually (with additional parameters)
dontWrapGApps = true;
buildInputs = [
qtbase qtimageformats gtk3 libappindicator-gtk3
dee ffmpeg openalSoft minizip libopus alsaLib libpulseaudio range-v3
];
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++"
] ++ concatMap (x: [
"-I${getDev qtbase}/include/${x}"
"-I${getDev qtbase}/include/${x}/${qtbase.version}"
"-I${getDev qtbase}/include/${x}/${qtbase.version}/${x}"
"-I${getDev libopus}/include/opus"
"-I${getDev alsaLib}/include/alsa"
"-I${getDev libpulseaudio}/include/pulse"
]) [ "QtCore" "QtGui" "QtDBus" ];
CPPFLAGS = NIX_CFLAGS_COMPILE;
preConfigure = ''
patch -R -Np1 -i "${archPatches}/demibold.patch"
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/qt.gypi \
-e "s,/usr/include/qt/QtCore/,${qtbase.dev}/include/QtCore/,g" \
-e 's,\d+",\d+" | head -n1,g'
sed -i Telegram/gyp/qt_moc.gypi \
-e "s,/usr/bin/moc,moc,g"
sed -i Telegram/gyp/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" ];
installPhase = ''
install -Dm755 Telegram $out/bin/telegram-desktop
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"
done
'';
dontWrapQtApps = true;
postFixup = ''
# 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)}\","
'';
meta = {
description = "Telegram Desktop messaging app "
+ (if stable then "(stable version)" else "(pre-release)");
license = licenses.gpl3;
platforms = platforms.linux;
homepage = https://desktop.telegram.org/;
maintainers = with maintainers; [ primeos abbradar ];
};
}

View File

@ -20597,8 +20597,14 @@ in
taskopen = callPackage ../applications/misc/taskopen { };
tdesktopPackages = dontRecurseIntoAttrs (callPackage ../applications/networking/instant-messengers/telegram/tdesktop { });
tdesktop = tdesktopPackages.stable;
# TODO (@primeos): Remove after the 19.09 branch-off:
tdesktopPackages = throw ''
The attributes "tdesktopPackages.*" where removed as the preview version
will not be maintained anymore (there are regular stable releases and we
depend on the patches from Arch Linux which only track the stable version
as well). Please switch to "tdesktop" (stable version).
'';
tdesktop = qt5.callPackage ../applications/networking/instant-messengers/telegram/tdesktop { };
telegram-cli = callPackage ../applications/networking/instant-messengers/telegram/telegram-cli { };