telegram-desktop: make webkitgtk optional

This commit is contained in:
Nick Cao
2024-11-03 18:09:13 -05:00
parent f9d1d5f00f
commit e17b7a15dd
7 changed files with 323 additions and 294 deletions
@@ -1,22 +1,16 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, callPackage
, libsForQt5
, yasm
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
libsForQt5,
yasm,
}:
let
telegram-desktop = libsForQt5.callPackage ../telegram-desktop { inherit stdenv; };
version = "1.4.9";
in
(libsForQt5.callPackage ../telegram-desktop/default.nix {
inherit stdenv;
tg_owt = (callPackage ../telegram-desktop/tg_owt.nix {
# tg_owt should use the same compiler
inherit stdenv;
}).overrideAttrs(oldAttrs: {
tg_owt = telegram-desktop.tg_owt.overrideAttrs (oldAttrs: {
version = "0-unstable-2024-06-15";
src = fetchFromGitHub {
@@ -27,7 +21,7 @@ in
fetchSubmodules = true;
};
patches = (oldAttrs.patches or []) ++ [
patches = (oldAttrs.patches or [ ]) ++ [
(fetchpatch {
url = "https://webrtc.googlesource.com/src/+/e7d10047096880feb5e9846375f2da54aef91202%5E%21/?format=TEXT";
decode = "base64 -d";
@@ -39,42 +33,44 @@ in
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ yasm ];
});
withWebKitGTK = false;
}).overrideAttrs {
in
telegram-desktop.override {
pname = "kotatogram-desktop";
version = "${version}-unstable-2024-09-27";
unwrapped = (telegram-desktop.unwrapped.override { inherit tg_owt; }).overrideAttrs {
pname = "kotatogram-desktop-unwrapped";
version = "${version}-unstable-2024-09-27";
src = fetchFromGitHub {
owner = "kotatogram";
repo = "kotatogram-desktop";
rev = "0581eb6219343b3cfcbb81124b372df1039b7568";
hash = "sha256-rvn8GZmHdMkVutLUe/LmUNIawlb9VgU3sYhPwZ2MWsI=";
fetchSubmodules = true;
};
src = fetchFromGitHub {
owner = "kotatogram";
repo = "kotatogram-desktop";
rev = "0581eb6219343b3cfcbb81124b372df1039b7568";
hash = "sha256-rvn8GZmHdMkVutLUe/LmUNIawlb9VgU3sYhPwZ2MWsI=";
fetchSubmodules = true;
};
patches = [
./macos-qt5.patch
(fetchpatch {
url = "https://gitlab.com/mnauw/cppgir/-/commit/c8bb1c6017a6f7f2e47bd10543aea6b3ec69a966.patch";
stripLen = 1;
extraPrefix = "cmake/external/glib/cppgir/";
hash = "sha256-8B4h3BTG8dIlt3+uVgBI569E9eCebcor9uohtsrZpnI=";
})
];
patches = [
./macos-qt5.patch
(fetchpatch {
url = "https://gitlab.com/mnauw/cppgir/-/commit/c8bb1c6017a6f7f2e47bd10543aea6b3ec69a966.patch";
stripLen = 1;
extraPrefix = "cmake/external/glib/cppgir/";
hash = "sha256-8B4h3BTG8dIlt3+uVgBI569E9eCebcor9uohtsrZpnI=";
})
];
meta = with lib; {
description = "Kotatogram experimental Telegram Desktop fork";
longDescription = ''
Unofficial desktop client for the Telegram messenger, based on Telegram Desktop.
meta = with lib; {
description = "Kotatogram experimental Telegram Desktop fork";
longDescription = ''
Unofficial desktop client for the Telegram messenger, based on Telegram Desktop.
It contains some useful (or purely cosmetic) features, but they could be unstable. A detailed list is available here: https://kotatogram.github.io/changes
'';
license = licenses.gpl3Only;
platforms = platforms.all;
homepage = "https://kotatogram.github.io";
changelog = "https://github.com/kotatogram/kotatogram-desktop/releases/tag/k${version}";
maintainers = with maintainers; [ ilya-fedin ];
mainProgram = if stdenv.hostPlatform.isLinux then "kotatogram-desktop" else "Kotatogram";
It contains some useful (or purely cosmetic) features, but they could be unstable. A detailed list is available here: https://kotatogram.github.io/changes
'';
license = licenses.gpl3Only;
platforms = platforms.all;
homepage = "https://kotatogram.github.io";
changelog = "https://github.com/kotatogram/kotatogram-desktop/releases/tag/k${version}";
maintainers = with maintainers; [ ilya-fedin ];
mainProgram = if stdenv.hostPlatform.isLinux then "kotatogram-desktop" else "Kotatogram";
};
};
}
@@ -1,23 +0,0 @@
{ stdenv, lib, kotatogram-desktop, glib-networking, webkitgtk_4_1, makeBinaryWrapper }:
stdenv.mkDerivation {
pname = "${kotatogram-desktop.pname}-with-webkit";
version = kotatogram-desktop.version;
nativeBuildInputs = [ makeBinaryWrapper ];
dontUnpack = true;
installPhase = ''
mkdir -p $out
cp -r ${kotatogram-desktop}/share $out
substituteInPlace $out/share/dbus-1/services/* --replace-fail ${kotatogram-desktop} $out
'';
postFixup = ''
mkdir -p $out/bin
makeBinaryWrapper {${kotatogram-desktop},$out}/bin/${kotatogram-desktop.meta.mainProgram} \
--inherit-argv0 \
--prefix GIO_EXTRA_MODULES : ${glib-networking}/lib/gio/modules \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ webkitgtk_4_1 ]}
'';
meta = kotatogram-desktop.meta // {
platforms = lib.platforms.linux;
};
}
@@ -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=";
};
inherit unwrapped;
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
'';
nativeBuildInputs =
[
wrapQtAppsHook
]
++ lib.optionals withWebkit [
wrapGAppsHook3
];
# Avoid double-wrapping
buildInputs =
[
qtbase
qtimageformats
qtsvg
]
++ lib.optionals stdenv.hostPlatform.isLinux [
qtwayland
]
++ lib.optionals withWebkit [
glib-networking
];
qtWrapperArgs = lib.optionals (stdenv.hostPlatform.isLinux && withWebkit) [
"--prefix"
"LD_LIBRARY_PATH"
":"
(lib.makeLibraryPath [ webkitgtk_4_1 ])
];
dontUnpack = true;
dontWrapGApps = true;
# Wrapping the inside of the app bundles, avoiding double-wrapping
dontWrapQtApps = stdenv.hostPlatform.isDarwin;
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
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
];
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")
];
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";
};
})
@@ -0,0 +1,150 @@
{
lib,
stdenv,
fetchFromGitHub,
callPackage,
pkg-config,
cmake,
ninja,
clang,
python3,
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,
libicns,
apple-sdk_15,
nix-update-script,
}:
# 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-unwrapped";
version = "5.6.3";
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"' '"${lib.getLib alsa-lib}/lib/libasound.so.2"'
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \
--replace-fail '"libasound.so.2"' '"${lib.getLib alsa-lib}/lib/libasound.so.2"'
substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp \
--replace-fail '"libpulse.so.0"' '"${lib.getLib libpulseaudio}/lib/libpulse.so.0"'
'';
nativeBuildInputs =
[
pkg-config
cmake
ninja
python3
]
++ lib.optionals stdenv.hostPlatform.isLinux [
# to build bundled libdispatch
clang
gobject-introspection
];
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.isDarwin [
apple-sdk_15
libicns
];
dontWrapQtApps = true;
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")
];
installPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
runHook preInstall
mkdir -p $out/Applications
cp -r ${finalAttrs.meta.mainProgram}.app $out/Applications
ln -sr $out/{Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS,bin}
runHook postInstall
'';
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.
'';
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";
};
})
+39 -39
View File
@@ -1,46 +1,46 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, telegram-desktop
, nix-update-script
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
telegram-desktop,
}:
telegram-desktop.overrideAttrs (old: rec {
telegram-desktop.override {
pname = "64gram";
version = "1.1.43";
unwrapped = telegram-desktop.unwrapped.overrideAttrs (old: rec {
pname = "64gram-unwrapped";
version = "1.1.43";
src = fetchFromGitHub {
owner = "TDesktop-x64";
repo = "tdesktop";
rev = "v${version}";
src = fetchFromGitHub {
owner = "TDesktop-x64";
repo = "tdesktop";
rev = "v${version}";
hash = "sha256-vRiAIGY3CU5+hsdn8xiNbgvSM3eGRVwnvsSmSoaDN/k=";
fetchSubmodules = true;
};
fetchSubmodules = true;
hash = "sha256-vRiAIGY3CU5+hsdn8xiNbgvSM3eGRVwnvsSmSoaDN/k=";
};
patches = (old.patches or [ ]) ++ [
(fetchpatch {
url = "https://github.com/TDesktop-x64/tdesktop/commit/c996ccc1561aed089c8b596f6ab3844335bbf1df.patch";
revert = true;
hash = "sha256-Hz7BXl5z4owe31l9Je3QOXT8FAyKcbsXsKjGfCmXhzE=";
})
];
patches = (old.patches or []) ++ [
(fetchpatch {
url = "https://github.com/TDesktop-x64/tdesktop/commit/c996ccc1561aed089c8b596f6ab3844335bbf1df.patch";
revert = true;
hash = "sha256-Hz7BXl5z4owe31l9Je3QOXT8FAyKcbsXsKjGfCmXhzE=";
})
];
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
(lib.cmakeBool "DESKTOP_APP_DISABLE_AUTOUPDATE" true)
(lib.cmakeBool "disable_autoupdate" true)
];
cmakeFlags = (old.cmakeFlags or []) ++ [
(lib.cmakeBool "DESKTOP_APP_DISABLE_AUTOUPDATE" true)
(lib.cmakeBool "disable_autoupdate" true)
];
passthru.updateScript = nix-update-script {};
meta = with lib; {
description = "Unofficial Telegram Desktop providing Windows 64bit build and extra features";
license = licenses.gpl3Only;
platforms = platforms.all;
homepage = "https://github.com/TDesktop-x64/tdesktop";
changelog = "https://github.com/TDesktop-x64/tdesktop/releases/tag/v${version}";
maintainers = with maintainers; [ clot27 ];
mainProgram = if stdenv.hostPlatform.isLinux then "telegram-desktop" else "Telegram";
};
})
meta = {
description = "Unofficial Telegram Desktop providing Windows 64bit build and extra features";
license = lib.licenses.gpl3Only;
platforms = lib.platforms.all;
homepage = "https://github.com/TDesktop-x64/tdesktop";
changelog = "https://github.com/TDesktop-x64/tdesktop/releases/tag/v${version}";
maintainers = with lib.maintainers; [ clot27 ];
mainProgram = if stdenv.hostPlatform.isLinux then "telegram-desktop" else "Telegram";
};
});
}
+32 -28
View File
@@ -1,34 +1,38 @@
{
telegram-desktop,
lib,
telegram-desktop,
fetchFromGitHub,
}:
telegram-desktop.overrideAttrs (
finalAttrs: previousAttrs: {
pname = "materialgram";
version = "5.6.1.1";
src = fetchFromGitHub {
owner = "kukuruzka165";
repo = "materialgram";
rev = "refs/tags/v${finalAttrs.version}";
fetchSubmodules = true;
hash = "sha256-e2ZLUooPMs0qB97BDyCiOUeD7cc+MuF5of65mEeJr04=";
};
telegram-desktop.override {
pname = "materialgram";
unwrapped = telegram-desktop.unwrapped.overrideAttrs (
finalAttrs: previousAttrs: {
pname = "materialgram-unwrapped";
version = "5.6.1.1";
meta = previousAttrs.meta // {
description = "Telegram Desktop fork with material icons and some improvements";
longDescription = ''
Telegram Desktop fork with Material Design and other improvements,
which is based on the Telegram API and the MTProto secure protocol.
'';
homepage = "https://kukuruzka165.github.io/materialgram/";
changelog = "https://github.com/kukuruzka165/materialgram/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [
oluceps
aleksana
];
mainProgram = "materialgram";
};
}
)
src = fetchFromGitHub {
owner = "kukuruzka165";
repo = "materialgram";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-e2ZLUooPMs0qB97BDyCiOUeD7cc+MuF5of65mEeJr04=";
fetchSubmodules = true;
};
meta = previousAttrs.meta // {
description = "Telegram Desktop fork with material icons and some improvements";
longDescription = ''
Telegram Desktop fork with Material Design and other improvements,
which is based on the Telegram API and the MTProto secure protocol.
'';
homepage = "https://kukuruzka165.github.io/materialgram/";
changelog = "https://github.com/kukuruzka165/materialgram/releases/tag/v${finalAttrs.version}";
maintainers = with lib.maintainers; [
oluceps
aleksana
];
mainProgram = "materialgram";
};
}
);
}
-2
View File
@@ -30201,8 +30201,6 @@ with pkgs;
kotatogram-desktop = callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop { };
kotatogram-desktop-with-webkit = callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop/with-webkit.nix { };
kpt = callPackage ../applications/networking/cluster/kpt { };
krabby = callPackage ../applications/misc/krabby { };