diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2023-11-20 02:36:39 +0400 |
---|---|---|
committer | Ilya Fedin <fedin-ilja2010@ya.ru> | 2023-11-20 02:36:39 +0400 |
commit | 533df7ae7523a1e6dd2235a20e65abaa08e3938d (patch) | |
tree | 6a233591962689141afc836ce8a7a8c00decbee7 /pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix | |
parent | 12a0ade5e458984675b9789a4b260ebabdd2d1ab (diff) |
telegram-desktop: build on Darwin
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix')
-rw-r--r-- | pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix | 90 |
1 files changed, 72 insertions, 18 deletions
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 e0d3a4171cacc..83a4f48142f11 100644 --- a/pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix +++ b/pkgs/applications/networking/instant-messengers/telegram/telegram-desktop/default.nix @@ -60,6 +60,9 @@ , mm-common , rlottie , stdenv +, darwin +, lld +, libicns , nix-update-script }: @@ -72,6 +75,7 @@ let tg_owt = callPackage ./tg_owt.nix { + inherit stdenv; abseil-cpp = abseil-cpp.override { cxxStandard = "20"; }; @@ -100,6 +104,7 @@ let perlPackages.XMLParser ]; }); + mainProgram = if stdenv.isLinux then "telegram-desktop" else "Telegram"; in stdenv.mkDerivation rec { pname = "telegram-desktop"; @@ -114,6 +119,7 @@ stdenv.mkDerivation rec { }; patches = [ + ./macos.patch # the generated .desktop files contains references to unwrapped tdesktop, breaking scheme handling # and the scheme handler is already registered in the packaged .desktop file, rendering this unnecessary # see https://github.com/NixOS/nixpkgs/issues/218370 @@ -123,7 +129,7 @@ stdenv.mkDerivation rec { }) ]; - postPatch = '' + postPatch = lib.optionalString stdenv.isLinux '' substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \ --replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \ @@ -143,39 +149,45 @@ stdenv.mkDerivation rec { cmake ninja python3 + wrapQtAppsHook + ] ++ lib.optionals stdenv.isLinux [ gobject-introspection wrapGAppsHook - wrapQtAppsHook extra-cmake-modules + ] ++ lib.optionals stdenv.isDarwin [ + lld ]; buildInputs = [ qtbase - qtwayland qtsvg qtimageformats - gtk3 boost - fmt - libdbusmenu lz4 xxHash ffmpeg openalSoft minizip libopus + range-v3 + tl-expected + rnnoise + protobuf + tg_owt + microsoft-gsl + rlottie + ] ++ lib.optionals stdenv.isLinux [ + qtwayland + gtk3 + fmt + libdbusmenu alsa-lib libpulseaudio pipewire - range-v3 - tl-expected hunspell glibmm webkitgtk_6_0 jemalloc - rnnoise - protobuf - tg_owt # Transitive dependencies: util-linuxMinimal # Required for libmount thus not nativeBuildInputs. pcre @@ -192,9 +204,44 @@ stdenv.mkDerivation rec { libsysprof-capture libpsl brotli - microsoft-gsl - rlottie - ]; + ] ++ lib.optionals stdenv.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.isDarwin { + NIX_CFLAGS_LINK = "-fuse-ld=lld"; + }; cmakeFlags = [ "-Ddisable_autoupdate=ON" @@ -210,13 +257,21 @@ stdenv.mkDerivation rec { export GI_GIR_PATH="$XDG_DATA_DIRS" ''; - postFixup = '' + installPhase = lib.optionalString stdenv.isDarwin '' + mkdir -p $out/Applications + cp -r ${mainProgram}.app $out/Applications + ln -s $out/{Applications/${mainProgram}.app/Contents/MacOS,bin} + ''; + + postFixup = lib.optionalString stdenv.isLinux '' # This is necessary to run Telegram in a pure environment. # We also use gappsWrapperArgs from wrapGAppsHook. - wrapProgram $out/bin/telegram-desktop \ + wrapProgram $out/bin/${mainProgram} \ "''${gappsWrapperArgs[@]}" \ "''${qtWrapperArgs[@]}" \ --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} + '' + lib.optionalString stdenv.isDarwin '' + wrapQtApp $out/Applications/${mainProgram}.app/Contents/MacOS/${mainProgram} ''; passthru = { @@ -231,10 +286,9 @@ stdenv.mkDerivation rec { the MTProto secure protocol. ''; license = licenses.gpl3Only; - platforms = platforms.linux; homepage = "https://desktop.telegram.org/"; changelog = "https://github.com/telegramdesktop/tdesktop/releases/tag/v${version}"; maintainers = with maintainers; [ nickcao ]; - mainProgram = "telegram-desktop"; + inherit mainProgram; }; } |