From a9ebf4d4cd6e54f56a4250fff5477e3dcd613498 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 4 May 2025 13:45:20 -0400 Subject: [PATCH 1/2] Revert "zoom-us: drop Darwin support" This reverts commit 27f0cbcf5450774981adb4b7ef651678a9cc9d17. Darwin support is still desired and there is nothing wrong in supporting it. MacOS doesn't need FHS hack. Signed-off-by: Ihar Hrachyshka --- pkgs/by-name/zo/zoom-us/package.nix | 147 +++++++++++++++++++--------- pkgs/by-name/zo/zoom-us/update.sh | 30 +++++- 2 files changed, 132 insertions(+), 45 deletions(-) diff --git a/pkgs/by-name/zo/zoom-us/package.nix b/pkgs/by-name/zo/zoom-us/package.nix index 00ac892e98f0..edcedf74d46a 100644 --- a/pkgs/by-name/zo/zoom-us/package.nix +++ b/pkgs/by-name/zo/zoom-us/package.nix @@ -2,6 +2,9 @@ stdenv, lib, fetchurl, + makeWrapper, + xar, + cpio, pulseaudioSupport ? true, xdgDesktopPortalSupport ? true, callPackage, @@ -9,39 +12,90 @@ }: let - unpacked = stdenv.mkDerivation (finalAttrs: { - pname = "zoom"; - version = "6.4.6.1370"; + inherit (stdenv.hostPlatform) system; + throwSystem = throw "Unsupported system: ${system}"; - src = fetchurl { - url = "https://zoom.us/client/${finalAttrs.version}/zoom_x86_64.pkg.tar.xz"; + # Zoom versions are released at different times for each platform + # and often with different versions. We write them on three lines + # like this (rather than using {}) so that the updater script can + # find where to edit them. + versions.aarch64-darwin = "6.4.6.53970"; + versions.x86_64-darwin = "6.4.6.53970"; + versions.x86_64-linux = "6.4.6.1370"; + + srcs = { + aarch64-darwin = fetchurl { + url = "https://zoom.us/client/${versions.aarch64-darwin}/zoomusInstallerFull.pkg?archType=arm64"; + name = "zoomusInstallerFull.pkg"; + hash = "sha256-yNsiFZNte4432d8DUyDhPUOVbLul7gUdvr+3qK/Y+tk="; + }; + x86_64-darwin = fetchurl { + url = "https://zoom.us/client/${versions.x86_64-darwin}/zoomusInstallerFull.pkg"; + hash = "sha256-Ut93qQFFN0d58wXD5r8u0B17HbihFg3FgY3a1L8nsIA="; + }; + x86_64-linux = fetchurl { + url = "https://zoom.us/client/${versions.x86_64-linux}/zoom_x86_64.pkg.tar.xz"; hash = "sha256-Y+8garSqDcKLCVv1cTiqGEfrGKpK3UoXIq8X4E8CF+8="; }; + }; - dontUnpack = true; + unpacked = stdenv.mkDerivation { + pname = "zoom"; + version = versions.${system} or throwSystem; - # Note: In order to uncover missing libraries, - # add "pkgs" to this file's arguments + src = srcs.${system} or throwSystem; + + dontUnpack = stdenv.hostPlatform.isLinux; + unpackPhase = lib.optionalString stdenv.hostPlatform.isDarwin '' + xar -xf $src + zcat < zoomus.pkg/Payload | cpio -i + ''; + + # Note: In order to uncover missing libraries + # on x86_64-linux, add "pkgs" to this file's arguments # (at the top of this file), then add these attributes here: # > buildInputs = linuxGetDependencies pkgs; # > dontAutoPatchelf = true; # > dontWrapQtApps = true; - # > nativeBuildInputs = [ pkgs.autoPatchelfHook ]; # > preFixup = '' # > addAutoPatchelfSearchPath $out/opt/zoom # > autoPatchelf $out/opt/zoom/{cef,Qt,*.so*,aomhost,zoom,zopen,ZoomLauncher,ZoomWebviewHost} # > ''; + # ...and finally "pkgs.autoPatchelfHook" + # to `nativeBuildInputs` right below. # Then build `zoom-us.unpacked`: # `autoPatchelfHook` will report missing library files. + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ + makeWrapper + xar + cpio + ]; installPhase = '' runHook preInstall - mkdir $out - tar -C $out -xf $src - mv $out/usr/* $out/ + ${ + rec { + aarch64-darwin = '' + mkdir -p $out/Applications + cp -R zoom.us.app $out/Applications/ + ''; + # darwin steps same on both architectures + x86_64-darwin = aarch64-darwin; + x86_64-linux = '' + mkdir $out + tar -C $out -xf $src + mv $out/usr/* $out/ + ''; + } + .${system} or throwSystem + } runHook postInstall ''; + postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' + makeWrapper $out/Applications/zoom.us.app/Contents/MacOS/zoom.us $out/bin/zoom + ''; + dontPatchELF = true; passthru.updateScript = ./update.sh; @@ -53,13 +107,18 @@ let description = "zoom.us video conferencing application"; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; license = lib.licenses.unfree; - platforms = [ "x86_64-linux" ]; + platforms = builtins.attrNames srcs; maintainers = with lib.maintainers; [ danbst tadfisher ]; + mainProgram = "zoom"; }; - }); + }; + packages.aarch64-darwin = unpacked; + packages.x86_64-darwin = unpacked; + + # linux definitions linuxGetDependencies = pkgs: @@ -132,35 +191,35 @@ let pkgs.xdg-desktop-portal-xapp ]; + # We add the `unpacked` zoom archive to the FHS env + # and also bind-mount its `/opt` directory. + # This should assist Zoom in finding all its + # files in the places where it expects them to be. + packages.x86_64-linux = buildFHSEnv { + pname = "zoom"; # Will also be the program's name! + version = versions.${system} or throwSystem; + + targetPkgs = pkgs: (linuxGetDependencies pkgs) ++ [ unpacked ]; + extraPreBwrapCmds = "unset QT_PLUGIN_PATH"; + extraBwrapArgs = [ "--ro-bind ${unpacked}/opt /opt" ]; + runScript = "/opt/zoom/ZoomLauncher"; + + extraInstallCommands = '' + cp -Rt $out/ ${unpacked}/share + substituteInPlace \ + $out/share/applications/Zoom.desktop \ + --replace-fail Exec={/usr/bin/,}zoom + + # Backwards compatibility: we used to call it zoom-us + ln -s $out/bin/{zoom,zoom-us} + ''; + + passthru = unpacked.passthru // { + inherit unpacked; + }; + inherit (unpacked) meta; + }; + in -# We add the `unpacked` zoom archive to the FHS env -# and also bind-mount its `/opt` directory. -# This should assist Zoom in finding all its -# files in the places where it expects them to be. -buildFHSEnv rec { - pname = "zoom"; # Will also be the program's name! - inherit (unpacked) version; - - targetPkgs = pkgs: (linuxGetDependencies pkgs) ++ [ unpacked ]; - extraPreBwrapCmds = "unset QT_PLUGIN_PATH"; - extraBwrapArgs = [ "--ro-bind ${unpacked}/opt /opt" ]; - runScript = "/opt/zoom/ZoomLauncher"; - - extraInstallCommands = '' - cp -Rt $out/ ${unpacked}/share - substituteInPlace \ - $out/share/applications/Zoom.desktop \ - --replace-fail Exec={/usr/bin/,}zoom - - # Backwards compatibility: we used to call it zoom-us - ln -s $out/bin/{zoom,zoom-us} - ''; - - passthru = unpacked.passthru // { - inherit unpacked; - }; - meta = unpacked.meta // { - mainProgram = pname; - }; -} +packages.${system} or throwSystem diff --git a/pkgs/by-name/zo/zoom-us/update.sh b/pkgs/by-name/zo/zoom-us/update.sh index 16d1e8f4fca0..df27da6f3ba4 100755 --- a/pkgs/by-name/zo/zoom-us/update.sh +++ b/pkgs/by-name/zo/zoom-us/update.sh @@ -3,4 +3,32 @@ set -eu -o pipefail -update-source-version zoom-us $(curl -Ls 'https://zoom.us/rest/download?os=linux' | jq -r .result.downloadVO.zoom.version) --source-key=unpacked.src +scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) +nixpkgs=$(realpath "$scriptDir"/../../../..) + +echo >&2 "=== Obtaining version data from https://zoom.us/rest/download ..." +linux_data=$(curl -Ls 'https://zoom.us/rest/download?os=linux' | jq .result.downloadVO) +mac_data=$(curl -Ls 'https://zoom.us/rest/download?os=mac' | jq .result.downloadVO) + +version_aarch64_darwin=$(jq -r .zoomArm64.version <<<"$mac_data") +version_x86_64_darwin=$(jq -r .zoom.version <<<"$mac_data") +version_x86_64_linux=$(jq -r .zoom.version <<<"$linux_data") + +echo >&2 "=== Downloading packages and computing hashes..." +# We precalculate the hashes before calling update-source-version +# because it attempts to calculate each architecture's package's hash +# by running `nix-build --system -A zoom-us.src` which +# causes cross compiling headaches; using nix-prefetch-url with +# hard-coded URLs is simpler. Keep these URLs in sync with the ones +# in package.nix where `srcs` is defined. +hash_aarch64_darwin=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "https://zoom.us/client/${version_aarch64_darwin}/zoomusInstallerFull.pkg?archType=arm64")) +hash_x86_64_darwin=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "https://zoom.us/client/${version_x86_64_darwin}/zoomusInstallerFull.pkg")) +hash_x86_64_linux=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "https://zoom.us/client/${version_x86_64_linux}/zoom_x86_64.pkg.tar.xz")) + +echo >&2 "=== Updating package.nix ..." +# update-source-version expects to be at the root of nixpkgs +(cd "$nixpkgs" && update-source-version zoom-us "$version_aarch64_darwin" $hash_aarch64_darwin --system=aarch64-darwin --version-key=versions.aarch64-darwin) +(cd "$nixpkgs" && update-source-version zoom-us "$version_x86_64_darwin" $hash_x86_64_darwin --system=x86_64-darwin --version-key=versions.x86_64-darwin) +(cd "$nixpkgs" && update-source-version zoom-us "$version_x86_64_linux" $hash_x86_64_linux --system=x86_64-linux --version-key=versions.x86_64-linux) + +echo >&2 "=== Done!" From ecf0deac76863884138e14a6bdd7b58c94c6bbe2 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 4 May 2025 14:52:47 -0400 Subject: [PATCH 2/2] zoom-us: fix update script for x86_64-linux Signed-off-by: Ihar Hrachyshka --- pkgs/by-name/zo/zoom-us/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/zo/zoom-us/update.sh b/pkgs/by-name/zo/zoom-us/update.sh index df27da6f3ba4..b7d7be55f1b8 100755 --- a/pkgs/by-name/zo/zoom-us/update.sh +++ b/pkgs/by-name/zo/zoom-us/update.sh @@ -29,6 +29,6 @@ echo >&2 "=== Updating package.nix ..." # update-source-version expects to be at the root of nixpkgs (cd "$nixpkgs" && update-source-version zoom-us "$version_aarch64_darwin" $hash_aarch64_darwin --system=aarch64-darwin --version-key=versions.aarch64-darwin) (cd "$nixpkgs" && update-source-version zoom-us "$version_x86_64_darwin" $hash_x86_64_darwin --system=x86_64-darwin --version-key=versions.x86_64-darwin) -(cd "$nixpkgs" && update-source-version zoom-us "$version_x86_64_linux" $hash_x86_64_linux --system=x86_64-linux --version-key=versions.x86_64-linux) +(cd "$nixpkgs" && update-source-version zoom-us "$version_x86_64_linux" $hash_x86_64_linux --system=x86_64-linux --version-key=versions.x86_64-linux --source-key=unpacked.src) echo >&2 "=== Done!"