diff --git a/pkgs/by-name/sl/slack/darwin.nix b/pkgs/by-name/sl/slack/darwin.nix new file mode 100644 index 000000000000..9d2245433d21 --- /dev/null +++ b/pkgs/by-name/sl/slack/darwin.nix @@ -0,0 +1,30 @@ +{ + pname, + version, + src, + passthru, + meta, + + stdenvNoCC, + undmg, +}: +stdenvNoCC.mkDerivation { + inherit + pname + version + src + passthru + meta + ; + + nativeBuildInputs = [ undmg ]; + + sourceRoot = "."; + + installPhase = '' + runHook preInstall + mkdir -p $out/Applications + cp -a Slack.app $out/Applications + runHook postInstall + ''; +} diff --git a/pkgs/by-name/sl/slack/linux.nix b/pkgs/by-name/sl/slack/linux.nix new file mode 100644 index 000000000000..03f6f10b21d0 --- /dev/null +++ b/pkgs/by-name/sl/slack/linux.nix @@ -0,0 +1,154 @@ +{ + pname, + version, + src, + passthru, + meta, + + lib, + stdenv, + dpkg, + makeWrapper, + asar, + alsa-lib, + at-spi2-atk, + at-spi2-core, + atk, + cairo, + cups, + curl, + dbus, + expat, + fontconfig, + freetype, + gdk-pixbuf, + glib, + gtk3, + libGL, + libappindicator-gtk3, + libdrm, + libnotify, + libpulseaudio, + libuuid, + libxcb, + libxkbcommon, + libgbm, + nspr, + nss, + pango, + pipewire, + systemd, + wayland, + xdg-utils, + xorg, +}: +stdenv.mkDerivation rec { + inherit + pname + version + src + passthru + meta + ; + + rpath = + lib.makeLibraryPath [ + alsa-lib + at-spi2-atk + at-spi2-core + atk + cairo + cups + curl + dbus + expat + fontconfig + freetype + gdk-pixbuf + glib + gtk3 + libGL + libappindicator-gtk3 + libdrm + libnotify + libpulseaudio + libuuid + libxcb + libxkbcommon + libgbm + nspr + nss + pango + pipewire + stdenv.cc.cc + systemd + wayland + xorg.libX11 + xorg.libXScrnSaver + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrandr + xorg.libXrender + xorg.libXtst + xorg.libxkbfile + xorg.libxshmfence + ] + + ":${lib.getLib stdenv.cc.cc}/lib64"; + + buildInputs = [ + gtk3 # needed for GSETTINGS_SCHEMAS_PATH + ]; + + nativeBuildInputs = [ + dpkg + makeWrapper + asar + ]; + + dontUnpack = true; + dontBuild = true; + dontPatchELF = true; + + installPhase = '' + runHook preInstall + + # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here + dpkg --fsys-tarfile $src | tar --extract + rm -rf usr/share/lintian + + mkdir -p $out + mv usr/* $out + + # Otherwise it looks "suspicious" + chmod -R g-w $out + + for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true + patchelf --set-rpath ${rpath}:$out/lib/slack $file || true + done + + # Replace the broken bin/slack symlink with a startup wrapper. + # Make xdg-open overrideable at runtime. + rm $out/bin/slack + makeWrapper $out/lib/slack/slack $out/bin/slack \ + --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \ + --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer --enable-wayland-ime=true}}" + + # Fix the desktop link + substituteInPlace $out/share/applications/slack.desktop \ + --replace /usr/bin/ $out/bin/ \ + --replace /usr/share/pixmaps/slack.png slack \ + --replace bin/slack "bin/slack -s" + + # Prevent Un-blacklist pipewire integration to enable screen sharing on wayland. + # https://github.com/flathub/com.slack.Slack/issues/101#issuecomment-1807073763 + sed -i -e 's/,"WebRTCPipeWireCapturer"/,"LebRTCPipeWireCapturer"/' $out/lib/slack/resources/app.asar + + runHook postInstall + ''; +} diff --git a/pkgs/by-name/sl/slack/package.nix b/pkgs/by-name/sl/slack/package.nix index 6259f4dfee21..1ccc339a2409 100644 --- a/pkgs/by-name/sl/slack/package.nix +++ b/pkgs/by-name/sl/slack/package.nix @@ -1,96 +1,29 @@ { - lib, - stdenv, + callPackage, fetchurl, - dpkg, - undmg, - makeWrapper, - asar, - alsa-lib, - at-spi2-atk, - at-spi2-core, - atk, - cairo, - cups, - curl, - dbus, - expat, - fontconfig, - freetype, - gdk-pixbuf, - glib, - gtk3, - libGL, - libappindicator-gtk3, - libdrm, - libnotify, - libpulseaudio, - libuuid, - libxcb, - libxkbcommon, - libxshmfence, - libgbm, - nspr, - nss, - pango, - pipewire, - systemd, - wayland, - xdg-utils, - xorg, + lib, + stdenvNoCC, }: let - inherit (stdenv.hostPlatform) system; - throwSystem = throw "slack does not support system: ${system}"; + inherit (stdenvNoCC.hostPlatform) system; + sources = import ./sources.nix { inherit fetchurl; }; pname = "slack"; - x86_64-darwin-version = "4.45.64"; - x86_64-darwin-sha256 = "0skhh16lc0czxd5ifkqy39hibk4ydlfhn41zdif3hl0sd4vcqbvb"; + passthru = { + updateScript = ./update.sh; + }; - x86_64-linux-version = "4.45.64"; - x86_64-linux-sha256 = "7c6af86ab1d5778aec930d4e7d77b9f9948a83a87e8458e821d6f9e8dfed180f"; - - aarch64-darwin-version = "4.45.64"; - aarch64-darwin-sha256 = "136crd17ybaznp680qb2rl0c8cllkkv21ymf3dck2jhkqbp7v2kj"; - - version = - { - x86_64-darwin = x86_64-darwin-version; - x86_64-linux = x86_64-linux-version; - aarch64-darwin = aarch64-darwin-version; - } - .${system} or throwSystem; - - src = - let - base = "https://downloads.slack-edge.com"; - in - { - x86_64-darwin = fetchurl { - url = "${base}/desktop-releases/mac/universal/${version}/Slack-${version}-macOS.dmg"; - sha256 = x86_64-darwin-sha256; - }; - x86_64-linux = fetchurl { - url = "${base}/desktop-releases/linux/x64/${version}/slack-desktop-${version}-amd64.deb"; - sha256 = x86_64-linux-sha256; - }; - aarch64-darwin = fetchurl { - url = "${base}/desktop-releases/mac/arm64/${version}/Slack-${version}-macOS.dmg"; - sha256 = aarch64-darwin-sha256; - }; - } - .${system} or throwSystem; - - meta = with lib; { + meta = { description = "Desktop client for Slack"; homepage = "https://slack.com"; changelog = "https://slack.com/release-notes"; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - license = licenses.unfree; - maintainers = with maintainers; [ + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = lib.licenses.unfree; + maintainers = with lib.maintainers; [ mmahut + prince213 teutat3s ]; platforms = [ @@ -100,141 +33,8 @@ let ]; mainProgram = "slack"; }; - - linux = stdenv.mkDerivation rec { - inherit - pname - version - src - meta - ; - - passthru.updateScript = ./update.sh; - - rpath = - lib.makeLibraryPath [ - alsa-lib - at-spi2-atk - at-spi2-core - atk - cairo - cups - curl - dbus - expat - fontconfig - freetype - gdk-pixbuf - glib - gtk3 - libGL - libappindicator-gtk3 - libdrm - libnotify - libpulseaudio - libuuid - libxcb - libxkbcommon - libgbm - nspr - nss - pango - pipewire - stdenv.cc.cc - systemd - wayland - xorg.libX11 - xorg.libXScrnSaver - xorg.libXcomposite - xorg.libXcursor - xorg.libXdamage - xorg.libXext - xorg.libXfixes - xorg.libXi - xorg.libXrandr - xorg.libXrender - xorg.libXtst - xorg.libxkbfile - xorg.libxshmfence - ] - + ":${lib.getLib stdenv.cc.cc}/lib64"; - - buildInputs = [ - gtk3 # needed for GSETTINGS_SCHEMAS_PATH - ]; - - nativeBuildInputs = [ - dpkg - makeWrapper - asar - ]; - - dontUnpack = true; - dontBuild = true; - dontPatchELF = true; - - installPhase = '' - runHook preInstall - - # The deb file contains a setuid binary, so 'dpkg -x' doesn't work here - dpkg --fsys-tarfile $src | tar --extract - rm -rf usr/share/lintian - - mkdir -p $out - mv usr/* $out - - # Otherwise it looks "suspicious" - chmod -R g-w $out - - for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true - patchelf --set-rpath ${rpath}:$out/lib/slack $file || true - done - - # Replace the broken bin/slack symlink with a startup wrapper. - # Make xdg-open overrideable at runtime. - rm $out/bin/slack - makeWrapper $out/lib/slack/slack $out/bin/slack \ - --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \ - --suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer --enable-wayland-ime=true}}" - - # Fix the desktop link - substituteInPlace $out/share/applications/slack.desktop \ - --replace /usr/bin/ $out/bin/ \ - --replace /usr/share/pixmaps/slack.png slack \ - --replace bin/slack "bin/slack -s" - '' - + lib.optionalString stdenv.hostPlatform.isLinux '' - # Prevent Un-blacklist pipewire integration to enable screen sharing on wayland. - # https://github.com/flathub/com.slack.Slack/issues/101#issuecomment-1807073763 - sed -i -e 's/,"WebRTCPipeWireCapturer"/,"LebRTCPipeWireCapturer"/' $out/lib/slack/resources/app.asar - '' - + '' - runHook postInstall - ''; - }; - - darwin = stdenv.mkDerivation { - inherit - pname - version - src - meta - ; - - passthru.updateScript = ./update.sh; - - nativeBuildInputs = [ undmg ]; - - sourceRoot = "Slack.app"; - - installPhase = '' - runHook preInstall - mkdir -p $out/Applications/Slack.app - cp -R . $out/Applications/Slack.app - runHook postInstall - ''; - }; in -if stdenv.hostPlatform.isDarwin then darwin else linux +callPackage (if stdenvNoCC.hostPlatform.isDarwin then ./darwin.nix else ./linux.nix) { + inherit pname passthru meta; + inherit (sources.${system} or (throw "Unsupported system: ${system}")) version src; +} diff --git a/pkgs/by-name/sl/slack/sources.nix b/pkgs/by-name/sl/slack/sources.nix new file mode 100644 index 000000000000..74b6d61ef559 --- /dev/null +++ b/pkgs/by-name/sl/slack/sources.nix @@ -0,0 +1,26 @@ +# Generated by ./update.sh - do not update manually! +# Last updated: 2025-08-29 +{ fetchurl }: +{ + aarch64-darwin = { + version = "4.45.69"; + src = fetchurl { + url = "https://downloads.slack-edge.com/desktop-releases/mac/arm64/4.45.69/Slack-4.45.69-macOS.dmg"; + hash = "sha256-MaPwj0niehwNYiSl8GdzKSF1mezKtIFiAmZzBWbwq9A="; + }; + }; + x86_64-darwin = { + version = "4.45.69"; + src = fetchurl { + url = "https://downloads.slack-edge.com/desktop-releases/mac/x64/4.45.69/Slack-4.45.69-macOS.dmg"; + hash = "sha256-iO5hGzYYmrHoTznw++AEhGjTKiTngzA9/ho+oFGXVeI="; + }; + }; + x86_64-linux = { + version = "4.45.69"; + src = fetchurl { + url = "https://downloads.slack-edge.com/desktop-releases/linux/x64/4.45.69/slack-desktop-4.45.69-amd64.deb"; + hash = "sha256-CwM8oEyRBkE5FSBO5rl4ygRuLtaRefVVZpAEHKxXKcw="; + }; + }; +} diff --git a/pkgs/by-name/sl/slack/update.sh b/pkgs/by-name/sl/slack/update.sh index 9a47575b1e7a..c54a9a5e7c29 100755 --- a/pkgs/by-name/sl/slack/update.sh +++ b/pkgs/by-name/sl/slack/update.sh @@ -1,47 +1,57 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p curl gnused +#! nix-shell -i bash --pure -p cacert curl jq nix -set -eou pipefail +set -euo pipefail -latest_linux_data="$(curl -s 'https://slack.com/api/desktop.latestRelease?arch=x64&variant=deb')" -latest_mac_data="$(curl -s 'https://slack.com/api/desktop.latestRelease?arch=universal&variant=dmg')" -latest_mac_arm_data="$(curl -s 'https://slack.com/api/desktop.latestRelease?arch=arm64&variant=dmg')" +cd $(readlink -e $(dirname "${BASH_SOURCE[0]}")) -latest_linux_version="$(echo ${latest_linux_data} | jq -rc '.version')" -latest_mac_version="$(echo ${latest_mac_data} | jq -rc '.version')" -latest_mac_arm_version="$(echo ${latest_mac_arm_data} | jq -rc '.version')" +aarch64_darwin_data=$(curl -s 'https://slack.com/api/desktop.latestRelease?arch=arm64&variant=dmg') +x86_64_darwin_data=$(curl -s 'https://slack.com/api/desktop.latestRelease?arch=x64&variant=dmg') +x86_64_linux_data=$(curl -s 'https://slack.com/api/desktop.latestRelease?arch=x64&variant=deb') -nixpkgs="$(git rev-parse --show-toplevel)" -slack_nix="$nixpkgs/pkgs/by-name/sl/slack/package.nix" -nixpkgs_linux_version=$(cat "$slack_nix" | sed -n 's/.*x86_64-linux-version = \"\([0-9\.]\+\)\";.*/\1/p') -nixpkgs_mac_version=$(cat "$slack_nix" | sed -n 's/.*x86_64-darwin-version = \"\([0-9\.]\+\)\";.*/\1/p') -nixpkgs_mac_arm_version=$(cat "$slack_nix" | sed -n 's/.*aarch64-darwin-version = \"\([0-9\.]\+\)\";.*/\1/p') +aarch64_darwin_version=$(jq -r .version <<< "$aarch64_darwin_data") +x86_64_darwin_version=$(jq -r .version <<< "$x86_64_darwin_data") +x86_64_linux_version=$(jq -r .version <<< "$x86_64_linux_data") -if [[ "$nixpkgs_linux_version" == "$latest_linux_version" && \ - "$nixpkgs_mac_version" == "$latest_mac_version" && \ - "$nixpkgs_mac_arm_version" == "$latest_mac_version" ]]; then - echo "nixpkgs versions are all up to date!" - exit 0 -fi +aarch64_darwin_url=$(jq -r .download_url <<< "$aarch64_darwin_data") +x86_64_darwin_url=$(jq -r .download_url <<< "$x86_64_darwin_data") +x86_64_linux_url=$(jq -r .download_url <<< "$x86_64_linux_data") -linux_url="$(echo ${latest_linux_data} | jq -rc '.download_url')" -mac_url="$(echo ${latest_mac_data} | jq -rc '.download_url')" -mac_arm_url="$(echo ${latest_mac_arm_data} | jq -rc '.download_url')" -linux_sha256=$(nix-prefetch-url ${linux_url}) -mac_sha256=$(nix-prefetch-url ${mac_url}) -mac_arm_sha256=$(nix-prefetch-url ${mac_arm_url}) +aarch64_darwin_hash=$(nix-prefetch-url "$aarch64_darwin_url") +x86_64_darwin_hash=$(nix-prefetch-url "$x86_64_darwin_url") +x86_64_linux_hash=$(nix-prefetch-url "$x86_64_linux_url") -sed -i "s/x86_64-linux-version = \".*\"/x86_64-linux-version = \"${latest_linux_version}\"/" "$slack_nix" -sed -i "s/x86_64-darwin-version = \".*\"/x86_64-darwin-version = \"${latest_mac_version}\"/" "$slack_nix" -sed -i "s/aarch64-darwin-version = \".*\"/aarch64-darwin-version = \"${latest_mac_version}\"/" "$slack_nix" -sed -i "s/x86_64-linux-sha256 = \".*\"/x86_64-linux-sha256 = \"${linux_sha256}\"/" "$slack_nix" -sed -i "s/x86_64-darwin-sha256 = \".*\"/x86_64-darwin-sha256 = \"${mac_sha256}\"/" "$slack_nix" -sed -i "s/aarch64-darwin-sha256 = \".*\"/aarch64-darwin-sha256 = \"${mac_arm_sha256}\"/" "$slack_nix" +# use friendlier hashes -if ! nix-build -A slack "$nixpkgs" --arg config '{ allowUnfree = true; }'; then - echo "The updated slack failed to build." - exit 1 -fi +aarch64_darwin_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$aarch64_darwin_hash") +x86_64_darwin_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$x86_64_darwin_hash") +x86_64_linux_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$x86_64_linux_hash") -echo "Successfully updated" -echo "slack: $nixpkgs_linux_version -> $latest_linux_version" +cat >sources.nix <