-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
telegram-desktop: make webkitgtk optional
- Loading branch information
Showing
5 changed files
with
322 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
210 changes: 57 additions & 153 deletions
210
pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,169 +1,73 @@ | ||
{ lib | ||
, stdenv | ||
, fetchFromGitHub | ||
, callPackage | ||
, pkg-config | ||
, cmake | ||
, ninja | ||
, clang | ||
, python3 | ||
, wrapQtAppsHook | ||
, tg_owt ? callPackage ./tg_owt.nix { inherit stdenv; } | ||
, qtbase | ||
, qtimageformats | ||
, qtsvg | ||
, qtwayland | ||
, kcoreaddons | ||
, lz4 | ||
, xxHash | ||
, ffmpeg | ||
, protobuf | ||
, openalSoft | ||
, minizip | ||
, libopus | ||
, alsa-lib | ||
, libpulseaudio | ||
, range-v3 | ||
, tl-expected | ||
, hunspell | ||
, gobject-introspection | ||
, jemalloc | ||
, rnnoise | ||
, microsoft-gsl | ||
, boost | ||
, ada | ||
, withWebKitGTK ? true | ||
, wrapGAppsHook3 | ||
, glib-networking | ||
, webkitgtk_4_1 | ||
, libicns | ||
, apple-sdk_15 | ||
, nix-update-script | ||
{ | ||
callPackage, | ||
lib, | ||
stdenv, | ||
pname ? "telegram-desktop", | ||
unwrapped ? callPackage ./unwrapped.nix { inherit stdenv; }, | ||
qtbase, | ||
qtimageformats, | ||
qtsvg, | ||
qtwayland, | ||
wrapGAppsHook3, | ||
wrapQtAppsHook, | ||
glib-networking, | ||
webkitgtk_4_1, | ||
withWebkit ? true, | ||
}: | ||
|
||
# Main reference: | ||
# - This package was originally based on the Arch package but all patches are now upstreamed: | ||
# https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/telegram-desktop | ||
# Other references that could be useful: | ||
# - https://git.alpinelinux.org/aports/tree/testing/telegram-desktop/APKBUILD | ||
# - https://github.com/void-linux/void-packages/blob/master/srcpkgs/telegram-desktop/template | ||
|
||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "telegram-desktop"; | ||
version = "5.6.3"; | ||
inherit pname; | ||
inherit (unwrapped) version meta passthru; | ||
|
||
src = fetchFromGitHub { | ||
owner = "telegramdesktop"; | ||
repo = "tdesktop"; | ||
rev = "v${finalAttrs.version}"; | ||
fetchSubmodules = true; | ||
hash = "sha256-frz425V5eRulNVxCf457TWQAzU/f9/szD/sx3/LYQ2Y="; | ||
}; | ||
|
||
postPatch = lib.optionalString stdenv.hostPlatform.isLinux '' | ||
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \ | ||
--replace-fail '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' | ||
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \ | ||
--replace-fail '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' | ||
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp \ | ||
--replace-fail '"libpulse.so.0"' '"${libpulseaudio}/lib/libpulse.so.0"' | ||
'' + lib.optionalString (stdenv.hostPlatform.isLinux && withWebKitGTK) '' | ||
substituteInPlace Telegram/lib_webview/webview/platform/linux/webview_linux_webkitgtk_library.cpp \ | ||
--replace-fail '"libwebkit2gtk-4.1.so.0"' '"${webkitgtk_4_1}/lib/libwebkit2gtk-4.1.so.0"' | ||
'' + lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
substituteInPlace Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm \ | ||
--replace-fail kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster | ||
''; | ||
inherit unwrapped; | ||
|
||
# Avoid double-wrapping | ||
dontWrapGApps = true; | ||
|
||
# Wrapping the inside of the app bundles, avoiding double-wrapping | ||
dontWrapQtApps = stdenv.hostPlatform.isDarwin; | ||
nativeBuildInputs = | ||
[ | ||
wrapQtAppsHook | ||
] | ||
++ lib.optionals withWebkit [ | ||
wrapGAppsHook3 | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
pkg-config | ||
cmake | ||
ninja | ||
python3 | ||
wrapQtAppsHook | ||
] ++ lib.optionals stdenv.hostPlatform.isLinux [ | ||
# to build bundled libdispatch | ||
clang | ||
gobject-introspection | ||
] ++ lib.optionals (stdenv.hostPlatform.isLinux && withWebKitGTK) [ | ||
wrapGAppsHook3 | ||
]; | ||
buildInputs = | ||
[ | ||
qtbase | ||
qtimageformats | ||
qtsvg | ||
] | ||
++ lib.optionals stdenv.hostPlatform.isLinux [ | ||
qtwayland | ||
] | ||
++ lib.optionals withWebkit [ | ||
glib-networking | ||
]; | ||
|
||
buildInputs = [ | ||
qtbase | ||
qtimageformats | ||
qtsvg | ||
lz4 | ||
xxHash | ||
ffmpeg | ||
openalSoft | ||
minizip | ||
libopus | ||
range-v3 | ||
tl-expected | ||
rnnoise | ||
tg_owt | ||
microsoft-gsl | ||
boost | ||
ada | ||
] ++ lib.optionals stdenv.hostPlatform.isLinux [ | ||
protobuf | ||
qtwayland | ||
kcoreaddons | ||
alsa-lib | ||
libpulseaudio | ||
hunspell | ||
jemalloc | ||
] ++ lib.optionals (stdenv.hostPlatform.isLinux && withWebKitGTK) [ | ||
glib-networking | ||
webkitgtk_4_1 | ||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ | ||
apple-sdk_15 | ||
libicns | ||
qtWrapperArgs = lib.optionals (stdenv.hostPlatform.isLinux && withWebkit) [ | ||
"--prefix" | ||
"LD_LIBRARY_PATH" | ||
":" | ||
(lib.makeLibraryPath [ webkitgtk_4_1 ]) | ||
]; | ||
|
||
cmakeFlags = [ | ||
# We're allowed to used the API ID of the Snap package: | ||
(lib.cmakeFeature "TDESKTOP_API_ID" "611335") | ||
(lib.cmakeFeature "TDESKTOP_API_HASH" "d524b414d21f4d37f08684c1df41ac9c") | ||
]; | ||
dontUnpack = true; | ||
dontWrapGApps = true; | ||
dontWrapQtApps = stdenv.hostPlatform.isDarwin; | ||
|
||
installPhase = lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
mkdir -p $out/Applications | ||
cp -r ${finalAttrs.meta.mainProgram}.app $out/Applications | ||
ln -s $out/{Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS,bin} | ||
installPhase = '' | ||
runHook preInstall | ||
cp -r "$unwrapped" "$out" | ||
runHook postInstall | ||
''; | ||
|
||
preFixup = lib.optionalString (stdenv.hostPlatform.isLinux && withWebKitGTK) '' | ||
preFixup = lib.optionalString (stdenv.hostPlatform.isLinux && withWebkit) '' | ||
qtWrapperArgs+=("''${gappsWrapperArgs[@]}") | ||
''; | ||
|
||
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
wrapQtApp $out/Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS/${finalAttrs.meta.mainProgram} | ||
''; | ||
|
||
passthru = { | ||
inherit tg_owt; | ||
updateScript = nix-update-script { }; | ||
}; | ||
|
||
meta = { | ||
description = "Telegram Desktop messaging app"; | ||
longDescription = '' | ||
Desktop client for the Telegram messenger, based on the Telegram API and | ||
the MTProto secure protocol. | ||
postFixup = | ||
lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
wrapQtApp "$out/Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS/${finalAttrs.meta.mainProgram}" | ||
'' | ||
+ lib.optionalString stdenv.hostPlatform.isLinux '' | ||
substituteInPlace $out/share/dbus-1/services/* \ | ||
--replace-fail "$unwrapped" "$out" | ||
''; | ||
license = lib.licenses.gpl3Only; | ||
platforms = lib.platforms.all; | ||
homepage = "https://desktop.telegram.org/"; | ||
changelog = "https://github.com/telegramdesktop/tdesktop/releases/tag/v${finalAttrs.version}"; | ||
maintainers = with lib.maintainers; [ nickcao ]; | ||
mainProgram = if stdenv.hostPlatform.isLinux then "telegram-desktop" else "Telegram"; | ||
}; | ||
}) |
Oops, something went wrong.