zoom-us: restore darwin support (#403993)

This commit is contained in:
Philip Taron 2025-05-06 14:39:41 -07:00 committed by GitHub
commit 03d65b92ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 132 additions and 45 deletions

View file

@ -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

View file

@ -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 <architecture> -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 --source-key=unpacked.src)
echo >&2 "=== Done!"