Skip to content

Commit

Permalink
kotatogram-desktop: override telegram-desktop's derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin committed Oct 31, 2024
1 parent 1c941e9 commit 39090b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,13 @@
, stdenv
, fetchFromGitHub
, callPackage
, pkg-config
, cmake
, ninja
, clang
, lld
, libsForQt5
, yasm
, python3
, wrapQtAppsHook
, removeReferencesTo
, 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
, libicns
, darwin
}:

let
(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;
Expand All @@ -54,10 +25,7 @@ let

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

mainProgram = if stdenv.hostPlatform.isLinux then "kotatogram-desktop" else "Kotatogram";
in
stdenv.mkDerivation rec {
}).overrideAttrs {
pname = "kotatogram-desktop";
version = "1.4.9-unstable-2024-09-27";

Expand All @@ -75,125 +43,7 @@ stdenv.mkDerivation rec {
./macos-qt5.patch
];

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.isDarwin ''
substituteInPlace Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm \
--replace-fail kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
'';

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

nativeBuildInputs = [
pkg-config
cmake
ninja
python3
wrapQtAppsHook
removeReferencesTo
] ++ lib.optionals stdenv.hostPlatform.isLinux [
# to build bundled libdispatch
clang
gobject-introspection
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
lld
];

buildInputs = [
qtbase
qtimageformats
qtsvg
lz4
xxHash
ffmpeg
openalSoft
minizip
libopus
range-v3
tl-expected
rnnoise
tg_owt
microsoft-gsl
boost
] ++ lib.optionals stdenv.hostPlatform.isLinux [
protobuf
qtwayland
kcoreaddons
alsa-lib
libpulseaudio
hunspell
jemalloc
] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk_11_0.frameworks; [
Cocoa
CoreFoundation
CoreServices
CoreText
CoreGraphics
CoreMedia
OpenGL
AudioUnit
ApplicationServices
Foundation
AGL
Security
SystemConfiguration
Carbon
AudioToolbox
VideoToolbox
VideoDecodeAcceleration
AVFoundation
CoreAudio
CoreVideo
CoreMediaIO
QuartzCore
AppKit
CoreWLAN
WebKit
IOKit
GSS
MediaPlayer
IOSurface
Metal
NaturalLanguage
libicns
]);

env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
NIX_CFLAGS_LINK = "-fuse-ld=lld";
};

cmakeFlags = [
"-DTDESKTOP_API_TEST=ON"
];

installPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
cp -r ${mainProgram}.app $out/Applications
ln -s $out/{Applications/${mainProgram}.app/Contents/MacOS,bin}
'';

preFixup = ''
remove-references-to -t ${stdenv.cc.cc} $out/bin/${mainProgram}
remove-references-to -t ${microsoft-gsl} $out/bin/${mainProgram}
remove-references-to -t ${tg_owt.dev} $out/bin/${mainProgram}
'';

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

passthru = {
inherit tg_owt;
};

meta = with lib; {
inherit mainProgram;
description = "Kotatogram – experimental Telegram Desktop fork";
longDescription = ''
Unofficial desktop client for the Telegram messenger, based on Telegram Desktop.
Expand All @@ -205,5 +55,6 @@ stdenv.mkDerivation rec {
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";
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
, python3
, wrapQtAppsHook
, removeReferencesTo
, tg_owt ? callPackage ./tg_owt.nix { inherit stdenv; }
, qtbase
, qtimageformats
, qtsvg
Expand Down Expand Up @@ -45,12 +46,6 @@
# - https://git.alpinelinux.org/aports/tree/testing/telegram-desktop/APKBUILD
# - https://github.com/void-linux/void-packages/blob/master/srcpkgs/telegram-desktop/template

let
tg_owt = callPackage ./tg_owt.nix {
# tg_owt should use the same compiler
inherit stdenv;
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "telegram-desktop";
version = "5.6.3";
Expand Down
6 changes: 2 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30248,15 +30248,13 @@ with pkgs;

kondo = callPackage ../applications/misc/kondo { };

kotatogram-desktop = libsForQt5.callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop {
kotatogram-desktop = callPackage ../applications/networking/instant-messengers/telegram/kotatogram-desktop {
stdenv = if stdenv.hostPlatform.isDarwin
then overrideSDK stdenv "11.0"
else stdenv;
};

kotatogram-desktop-with-webkit = callPackage ../applications/networking/instant-messengers/telegram/telegram-desktop/with-webkit.nix {
telegram-desktop = kotatogram-desktop;
};
kotatogram-desktop-with-webkit = kotatogram-desktop.with-webkit;

kpt = callPackage ../applications/networking/cluster/kpt { };

Expand Down

0 comments on commit 39090b8

Please sign in to comment.