From 39090b8c1cb80e46baa50d9d80181374cf1ae605 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 31 Oct 2024 16:27:00 +0400 Subject: [PATCH] kotatogram-desktop: override telegram-desktop's derivation --- .../telegram/kotatogram-desktop/default.nix | 161 +----------------- .../telegram/telegram-desktop/default.nix | 7 +- pkgs/top-level/all-packages.nix | 6 +- 3 files changed, 9 insertions(+), 165 deletions(-) diff --git a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix index 0b52d3f38a7e9a..92ac2c4473432f 100644 --- a/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix +++ b/pkgs/applications/networking/instant-messengers/telegram/kotatogram-desktop/default.nix @@ -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; @@ -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"; @@ -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. @@ -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"; }; } diff --git a/pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix b/pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix index 3deb9da036a2fd..48e2ce9035f8b5 100644 --- a/pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix +++ b/pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix @@ -10,6 +10,7 @@ , python3 , wrapQtAppsHook , removeReferencesTo +, tg_owt ? callPackage ./tg_owt.nix { inherit stdenv; } , qtbase , qtimageformats , qtsvg @@ -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"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2d7e4fe9f67352..acc21f57aa04a0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };