Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d24360033de6
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ce08cf0a29b0
Choose a head ref
  • 4 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 4, 2020

  1. Copy the full SHA
    04990cd View commit details
  2. Copy the full SHA
    f0fc696 View commit details

Commits on Nov 5, 2020

  1. Copy the full SHA
    3037318 View commit details
  2. Copy the full SHA
    ce08cf0 View commit details
Showing with 56 additions and 4 deletions.
  1. +15 −4 pkgs/applications/networking/instant-messengers/slack/default.nix
  2. +41 −0 pkgs/applications/networking/instant-messengers/slack/update.sh
19 changes: 15 additions & 4 deletions pkgs/applications/networking/instant-messengers/slack/default.nix
Original file line number Diff line number Diff line change
@@ -39,21 +39,28 @@ let
throwSystem = throw "Unsupported system: ${system}";

pname = "slack";

x86_64-darwin-version = "4.10.3";
x86_64-darwin-sha256 = "0r77l57vr603xamich4h4gbdd5vdcj0sjs6yjpymfx9s0f98v8bb";

x86_64-linux-version = "4.10.3";
x86_64-linux-sha256 = "1gnjj2iyk8cwjajg8h9qpmzx10j4qjxjzciq8csg45qfzwkr3drf";

version = {
x86_64-darwin = "4.10.3";
x86_64-linux = "4.10.3";
x86_64-darwin = x86_64-darwin-version;
x86_64-linux = x86_64-linux-version;
}.${system} or throwSystem;

src = let
base = "https://downloads.slack-edge.com";
in {
x86_64-darwin = fetchurl {
url = "${base}/releases/macos/${version}/prod/x64/Slack-${version}-macOS.dmg";
sha256 = "0r77l57vr603xamich4h4gbdd5vdcj0sjs6yjpymfx9s0f98v8bb";
sha256 = x86_64-darwin-sha256;
};
x86_64-linux = fetchurl {
url = "${base}/linux_releases/slack-desktop-${version}-amd64.deb";
sha256 = "1gnjj2iyk8cwjajg8h9qpmzx10j4qjxjzciq8csg45qfzwkr3drf";
sha256 = x86_64-linux-sha256;
};
}.${system} or throwSystem;

@@ -68,6 +75,8 @@ let
linux = stdenv.mkDerivation rec {
inherit pname version src meta;

passthru.updateScript = ./update.sh;

rpath = stdenv.lib.makeLibraryPath [
alsaLib
at-spi2-atk
@@ -152,6 +161,8 @@ let
darwin = stdenv.mkDerivation {
inherit pname version src meta;

passthru.updateScript = ./update.sh;

nativeBuildInputs = [ undmg ];

sourceRoot = "Slack.app";
41 changes: 41 additions & 0 deletions pkgs/applications/networking/instant-messengers/slack/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p curl gnused

set -eou pipefail

latest_linux_version=$(curl --silent https://slack.com/downloads/linux | sed -n 's/.*Version \([0-9\.]\+\).*/\1/p')
latest_mac_version=$(curl --silent https://slack.com/downloads/mac | sed -n 's/.*Version \([0-9\.]\+\).*/\1/p')

# Double check that the latest mac and linux versions are in sync.
if [[ "$latest_linux_version" != "$latest_mac_version" ]]; then
echo "the latest linux ($latest_linux_version) and mac ($latest_mac_version) versions are not the same"
exit 1
fi

nixpkgs="$(git rev-parse --show-toplevel)"
slack_nix="$nixpkgs/pkgs/applications/networking/instant-messengers/slack/default.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')

if [[ "$nixpkgs_linux_version" == "$latest_linux_version" && "$nixpkgs_mac_version" == "$latest_mac_version" ]]; then
echo "nixpkgs versions are all up to date!"
exit 0
fi

linux_url="https://downloads.slack-edge.com/linux_releases/slack-desktop-${latest_linux_version}-amd64.deb"
mac_url="https://downloads.slack-edge.com/releases/macos/${latest_mac_version}/prod/x64/Slack-${latest_mac_version}-macOS.dmg"
linux_sha256=$(nix-prefetch-url ${linux_url})
mac_sha256=$(nix-prefetch-url ${mac_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/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"

if ! nix-build -A slack "$nixpkgs"; then
echo "The updated slack failed to build."
exit 1
fi

echo "Successfully updated"
echo "slack: $nixpkgs_linux_version -> $latest_linux_version"