Skip to content

Commit

Permalink
telegram-desktop: make webkitgtk dependency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin committed Nov 3, 2024
1 parent eae1f31 commit c8e55aa
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let
version = "1.4.9";
in
(libsForQt5.callPackage ../telegram-desktop/default.nix {
((libsForQt5.callPackage ../telegram-desktop/default.nix {
inherit stdenv;

tg_owt = (callPackage ../telegram-desktop/tg_owt.nix {
Expand Down Expand Up @@ -39,9 +39,7 @@ in

nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ yasm ];
});

withWebKitGTK = false;
}).overrideAttrs {
}).without-webkit.overrideAttrs {
pname = "kotatogram-desktop";
version = "${version}-unstable-2024-09-27";

Expand Down Expand Up @@ -77,4 +75,4 @@ in
maintainers = with maintainers; [ ilya-fedin ];
mainProgram = if stdenv.hostPlatform.isLinux then "kotatogram-desktop" else "Kotatogram";
};
}
}).with-webkit

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
, microsoft-gsl
, boost
, ada
, withWebKitGTK ? true
, wrapGAppsHook3
, glib-networking
, webkitgtk_4_1
, libicns
, apple-sdk_15
, nix-update-script
Expand All @@ -48,7 +44,7 @@
# - 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: {
(stdenv.mkDerivation (finalAttrs: {
pname = "telegram-desktop";
version = "5.6.3";

Expand All @@ -67,17 +63,11 @@ stdenv.mkDerivation (finalAttrs: {
--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
'';

# Avoid double-wrapping
dontWrapGApps = true;

# Wrapping the inside of the app bundles, avoiding double-wrapping
dontWrapQtApps = stdenv.hostPlatform.isDarwin;

Expand All @@ -91,8 +81,6 @@ stdenv.mkDerivation (finalAttrs: {
# to build bundled libdispatch
clang
gobject-introspection
] ++ lib.optionals (stdenv.hostPlatform.isLinux && withWebKitGTK) [
wrapGAppsHook3
];

buildInputs = [
Expand Down Expand Up @@ -120,9 +108,6 @@ stdenv.mkDerivation (finalAttrs: {
libpulseaudio
hunspell
jemalloc
] ++ lib.optionals (stdenv.hostPlatform.isLinux && withWebKitGTK) [
glib-networking
webkitgtk_4_1
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_15
libicns
Expand All @@ -140,15 +125,15 @@ stdenv.mkDerivation (finalAttrs: {
ln -s $out/{Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS,bin}
'';

preFixup = lib.optionalString (stdenv.hostPlatform.isLinux && withWebKitGTK) ''
qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
'';

postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
wrapQtApp $out/Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS/${finalAttrs.meta.mainProgram}
'';

passthru = {
with-webkit = callPackage ./with-webkit.nix {
telegram-desktop = finalAttrs.finalPackage;
};
without-webkit = finalAttrs.finalPackage;
inherit tg_owt;
updateScript = nix-update-script { };
};
Expand All @@ -166,4 +151,4 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with lib.maintainers; [ nickcao ];
mainProgram = if stdenv.hostPlatform.isLinux then "telegram-desktop" else "Telegram";
};
})
})).with-webkit
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
stdenv,
lib,
telegram-desktop,
glib-networking,
webkitgtk_4_1,
makeBinaryWrapper,
}:

if stdenv.hostPlatform.isLinux then
stdenv.mkDerivation {
pname = "${telegram-desktop.pname}-with-webkit";
version = telegram-desktop.version;
nativeBuildInputs = [ makeBinaryWrapper ];
dontUnpack = true;
installPhase = ''
mkdir -p $out
cp -r ${telegram-desktop}/share $out
substituteInPlace $out/share/dbus-1/services/* --replace-fail ${telegram-desktop} $out
'';
postFixup = ''
mkdir -p $out/bin
makeBinaryWrapper {${telegram-desktop},$out}/bin/${telegram-desktop.meta.mainProgram} \
--inherit-argv0 \
--prefix GIO_EXTRA_MODULES : ${glib-networking}/lib/gio/modules \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ webkitgtk_4_1 ]}
'';
passthru = telegram-desktop.passthru;
meta = telegram-desktop.meta // {
platforms = lib.platforms.linux;
};
}
else
telegram-desktop
6 changes: 3 additions & 3 deletions pkgs/by-name/_6/_64gram/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
, nix-update-script
}:

telegram-desktop.overrideAttrs (old: rec {
(telegram-desktop.without-webkit.overrideAttrs (old: rec {
pname = "64gram";
version = "1.1.43";

Expand All @@ -32,7 +32,7 @@ telegram-desktop.overrideAttrs (old: rec {
(lib.cmakeBool "disable_autoupdate" true)
];

passthru.updateScript = nix-update-script {};
passthru = (old.passthru or {}) // { updateScript = nix-update-script {}; };

meta = with lib; {
description = "Unofficial Telegram Desktop providing Windows 64bit build and extra features";
Expand All @@ -43,4 +43,4 @@ telegram-desktop.overrideAttrs (old: rec {
maintainers = with maintainers; [ clot27 ];
mainProgram = if stdenv.hostPlatform.isLinux then "telegram-desktop" else "Telegram";
};
})
})).with-webkit
4 changes: 2 additions & 2 deletions pkgs/by-name/ma/materialgram/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
lib,
fetchFromGitHub,
}:
telegram-desktop.overrideAttrs (
(telegram-desktop.without-webkit.overrideAttrs (
finalAttrs: previousAttrs: {
pname = "materialgram";
version = "5.6.1.1";
Expand Down Expand Up @@ -31,4 +31,4 @@ telegram-desktop.overrideAttrs (
mainProgram = "materialgram";
};
}
)
)).with-webkit
2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30211,8 +30211,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 { };
Expand Down

0 comments on commit c8e55aa

Please sign in to comment.