From b031816f58e7c8454e96c3d7c01e26002986cbef Mon Sep 17 00:00:00 2001 From: kashw2 Date: Mon, 15 Sep 2025 01:06:31 +1000 Subject: [PATCH] nextcloud-talk-desktop: add darwin support --- .../ne/nextcloud-talk-desktop/package.nix | 208 +++++++++++------- 1 file changed, 127 insertions(+), 81 deletions(-) diff --git a/pkgs/by-name/ne/nextcloud-talk-desktop/package.nix b/pkgs/by-name/ne/nextcloud-talk-desktop/package.nix index c17cbca9ef66b..327d698d5368b 100644 --- a/pkgs/by-name/ne/nextcloud-talk-desktop/package.nix +++ b/pkgs/by-name/ne/nextcloud-talk-desktop/package.nix @@ -21,97 +21,143 @@ libglvnd, systemd, nix-update-script, + undmg, + makeWrapper, }: - -stdenv.mkDerivation (finalAttrs: { +let pname = "nextcloud-talk-desktop"; version = "2.0.3"; - # Building from source would require building also building Server and Talk components - # See https://github.com/nextcloud/talk-desktop?tab=readme-ov-file#%EF%B8%8F-prerequisites - src = fetchzip { - url = "https://github.com/nextcloud-releases/talk-desktop/releases/download/v${finalAttrs.version}/Nextcloud.Talk-linux-x64.zip"; - hash = "sha256-QKbg5vHLuxLpngrHom/odWw9RK43jhZsEg7Df5c7db0="; - stripRoot = false; - }; - - icon = fetchurl { - url = "https://raw.githubusercontent.com/nextcloud/talk-desktop/refs/tags/v1.0.0/img/icons/icon.png"; - hash = "sha256-DteSSuxIs0ukIJrvUO/3Mrh5F2GG5UAVvGRZUuZonkg="; + # Only x86_64-linux is supported with Darwin support being universal + sources = { + # Building from source would require building also building Server and Talk components + # See https://github.com/nextcloud/talk-desktop?tab=readme-ov-file#%EF%B8%8F-prerequisites + linux = fetchzip { + url = "https://github.com/nextcloud-releases/talk-desktop/releases/download/v${version}/Nextcloud.Talk-linux-x64.zip"; + hash = "sha256-QKbg5vHLuxLpngrHom/odWw9RK43jhZsEg7Df5c7db0="; + stripRoot = false; + }; + darwin = fetchurl { + url = "https://github.com/nextcloud-releases/talk-desktop/releases/download/v${version}/Nextcloud.Talk-macos-universal.dmg"; + hash = "sha256-FgiUb2MNEqmbK4BphHQ7M2IeN7Vg1NQ9FR9UO4AfvNs="; + }; }; - nativeBuildInputs = [ - autoPatchelfHook - copyDesktopItems - ]; - - buildInputs = [ - nss - cairo - alsa-lib - at-spi2-core - pango - libdrm - libxkbcommon - gtk3 - vivaldi-ffmpeg-codecs - libgbm - libGL - libglvnd - ] - ++ (with xorg; [ - libX11 - libXcomposite - libXdamage - libXrandr - libXfixes - libXcursor - ]); - - # Required to launch the application and proceed past the zygote_linux fork() process - # Fixes `Zygote could not fork` - runtimeDependencies = [ systemd ]; - - desktopItems = [ - (makeDesktopItem { - type = "Application"; - name = "nextcloud-talk-desktop"; - desktopName = "Nextcloud Talk"; - comment = finalAttrs.meta.description; - exec = finalAttrs.meta.mainProgram; - icon = "nextcloud-talk-desktop"; - categories = [ "Chat" ]; - }) - ]; - - preInstall = '' - mkdir -p $out/bin - mkdir -p $out/opt - - cp -r $src/* $out/opt/ - ''; - - installPhase = '' - runHook preInstall - - # Link the application in $out/bin away from contents of `preInstall` - ln -s "$out/opt/Nextcloud Talk-linux-x64/Nextcloud Talk" $out/bin/nextcloud-talk-desktop - mkdir -p $out/share/icons/hicolor/512x512/apps - cp $icon $out/share/icons/hicolor/512x512/apps/nextcloud-talk-desktop.png - - runHook postInstall - ''; - - passthru.updateScript = nix-update-script { }; - meta = { description = "Nextcloud Talk Desktop Client"; homepage = "https://github.com/nextcloud/talk-desktop"; - changelog = "https://github.com/nextcloud/talk-desktop/blob/${finalAttrs.version}/CHANGELOG.md"; + changelog = "https://github.com/nextcloud/talk-desktop/blob/${version}/CHANGELOG.md"; license = lib.licenses.agpl3Only; maintainers = with lib.maintainers; [ kashw2 ]; - mainProgram = "nextcloud-talk-desktop"; sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; - platforms = [ "x86_64-linux" ]; + mainProgram = "nextcloud-talk-desktop"; }; -}) + + linux = stdenv.mkDerivation (finalAttrs: { + inherit pname version; + + src = sources.linux; + + icon = fetchurl { + url = "https://raw.githubusercontent.com/nextcloud/talk-desktop/refs/tags/v${version}/img/icons/icon.png"; + hash = "sha256-DteSSuxIs0ukIJrvUO/3Mrh5F2GG5UAVvGRZUuZonkg="; + }; + + nativeBuildInputs = [ + autoPatchelfHook + copyDesktopItems + ]; + + buildInputs = [ + nss + cairo + alsa-lib + at-spi2-core + pango + libdrm + libxkbcommon + gtk3 + vivaldi-ffmpeg-codecs + libgbm + libGL + libglvnd + ] + ++ (with xorg; [ + libX11 + libXcomposite + libXdamage + libXrandr + libXfixes + libXcursor + ]); + + # Required to launch the application and proceed past the zygote_linux fork() process + # Fixes `Zygote could not fork` + runtimeDependencies = [ systemd ]; + + desktopItems = [ + (makeDesktopItem { + type = "Application"; + name = "nextcloud-talk-desktop"; + desktopName = "Nextcloud Talk"; + comment = finalAttrs.meta.description; + exec = finalAttrs.meta.mainProgram; + icon = "nextcloud-talk-desktop"; + categories = [ "Chat" ]; + }) + ]; + + preInstall = '' + mkdir -p $out/bin + mkdir -p $out/opt + + cp -r $src/* $out/opt/ + ''; + + installPhase = '' + runHook preInstall + + # Link the application in $out/bin away from contents of `preInstall` + ln -s "$out/opt/Nextcloud Talk-linux-x64/Nextcloud Talk" $out/bin/nextcloud-talk-desktop + mkdir -p $out/share/icons/hicolor/512x512/apps + cp $icon $out/share/icons/hicolor/512x512/apps/nextcloud-talk-desktop.png + + runHook postInstall + ''; + + passthru.updateScript = nix-update-script { }; + + meta = meta // { + platforms = lib.intersectLists lib.platforms.linux lib.platforms.x86_64; + }; + }); + + darwin = stdenv.mkDerivation (finalAttrs: { + inherit pname version; + + src = sources.darwin; + + nativeBuildInputs = [ + undmg + makeWrapper + ]; + + sourceRoot = "."; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{Applications,bin} + mv Nextcloud\ Talk.app/Contents $out/Applications/ + + makeWrapper $out/Applications/Contents/MacOS/Nextcloud\ Talk $out/bin/nextcloud-talk-desktop + + runHook postInstall + ''; + + meta = meta // { + platforms = lib.platforms.darwin; + }; + }); +in +if stdenv.hostPlatform.isDarwin then darwin else linux