nixpkgs-suyu/pkgs/applications/networking/instant-messengers/slack/default.nix

205 lines
4.5 KiB
Nix
Raw Normal View History

2021-06-23 16:32:48 +02:00
{ lib
, stdenv
, fetchurl
, dpkg
, undmg
, makeWrapper
, nodePackages
, alsa-lib
, at-spi2-atk
, at-spi2-core
, atk
, cairo
, cups
, curl
, dbus
, expat
, fontconfig
, freetype
, gdk-pixbuf
, glib
, gnome2
, gtk3
2021-06-23 16:32:48 +02:00
, libGL
, libappindicator-gtk3
, libdrm
, libnotify
, libpulseaudio
, libuuid
, libxcb
2020-11-16 07:29:21 +01:00
, libxkbcommon
2021-03-31 09:12:34 +02:00
, libxshmfence
, mesa
, nspr
, nss
, pango
2021-10-20 10:01:48 +02:00
, pipewire
, systemd
2021-02-01 09:05:09 +01:00
, xdg-utils
, xorg
}:
2016-03-22 21:05:02 +01:00
let
2020-02-17 22:35:43 +01:00
inherit (stdenv.hostPlatform) system;
throwSystem = throw "Unsupported system: ${system}";
2016-03-22 21:05:02 +01:00
pname = "slack";
2021-11-23 05:55:36 +01:00
x86_64-darwin-version = "4.22.0";
x86_64-darwin-sha256 = "094p9vyv56m5qfp9jh2205ijfqcp0dr6bkmiv0wxihy2rg20b5zp";
2021-11-23 05:55:36 +01:00
x86_64-linux-version = "4.22.0";
x86_64-linux-sha256 = "0k84glxp653lxgfv5b65zvvysax7fr3lhsjgq76safk7g7cjc86i";
2021-11-23 05:55:36 +01:00
aarch64-darwin-version = "4.22.0";
aarch64-darwin-sha256 = "1z2pcgva9ixjx702c1535b4k0xr9fdnfzi5m08xgvabk9x66hqx4";
version = {
x86_64-darwin = x86_64-darwin-version;
aarch64-darwin = aarch64-darwin-version;
x86_64-linux = x86_64-linux-version;
2020-04-27 14:10:35 +02:00
}.${system} or throwSystem;
2021-06-23 16:32:48 +02:00
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 = x86_64-darwin-sha256;
};
aarch64-darwin = fetchurl {
url = "${base}/releases/macos/${version}/prod/arm64/Slack-${version}-macOS.dmg";
sha256 = aarch64-darwin-sha256;
};
2021-06-23 16:32:48 +02:00
x86_64-linux = fetchurl {
2021-10-05 09:46:29 +02:00
url = "${base}/releases/linux/${version}/prod/x64/slack-desktop-${version}-amd64.deb";
2021-06-23 16:32:48 +02:00
sha256 = x86_64-linux-sha256;
};
}.${system} or throwSystem;
meta = with lib; {
2016-03-22 21:05:02 +01:00
description = "Desktop client for Slack";
homepage = "https://slack.com";
2016-03-22 21:05:02 +01:00
license = licenses.unfree;
maintainers = with maintainers; [ mmahut ];
platforms = [ "x86_64-darwin" "x86_64-linux" "aarch64-darwin"];
2020-02-17 22:35:43 +01:00
};
linux = stdenv.mkDerivation rec {
inherit pname version src meta;
2020-02-17 22:35:43 +01:00
2020-11-05 01:12:36 +01:00
passthru.updateScript = ./update.sh;
2021-01-15 06:42:41 +01:00
rpath = lib.makeLibraryPath [
alsa-lib
2020-02-17 22:35:43 +01:00
at-spi2-atk
at-spi2-core
atk
cairo
cups
curl
dbus
expat
fontconfig
freetype
gdk-pixbuf
2020-02-17 22:35:43 +01:00
glib
gnome2.GConf
gtk3
2021-06-23 16:32:48 +02:00
libGL
libappindicator-gtk3
libdrm
2020-02-17 22:35:43 +01:00
libnotify
libpulseaudio
libuuid
2020-02-17 22:35:43 +01:00
libxcb
2020-11-16 07:29:21 +01:00
libxkbcommon
mesa
2020-02-17 22:35:43 +01:00
nspr
nss
pango
2021-10-20 10:01:48 +02:00
pipewire
2020-02-17 22:35:43 +01:00
stdenv.cc.cc
systemd
xorg.libX11
xorg.libXScrnSaver
2020-02-17 22:35:43 +01:00
xorg.libXcomposite
xorg.libXcursor
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXi
xorg.libXrandr
xorg.libXrender
xorg.libXtst
xorg.libxkbfile
2021-06-23 16:32:48 +02:00
xorg.libxshmfence
2020-02-17 22:35:43 +01:00
] + ":${stdenv.cc.cc.lib}/lib64";
buildInputs = [
2021-06-23 16:32:48 +02:00
gtk3 # needed for GSETTINGS_SCHEMAS_PATH
2020-02-17 22:35:43 +01:00
];
2020-02-17 22:35:43 +01:00
nativeBuildInputs = [ dpkg makeWrapper nodePackages.asar ];
2020-02-17 22:35:43 +01:00
dontUnpack = true;
dontBuild = true;
dontPatchELF = true;
2020-02-17 22:35:43 +01:00
installPhase = ''
runHook preInstall
2020-02-17 22:35:43 +01:00
# 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
2020-02-17 22:35:43 +01:00
mkdir -p $out
mv usr/* $out
2020-02-17 22:35:43 +01:00
# Otherwise it looks "suspicious"
chmod -R g-w $out
2020-02-17 22:35:43 +01:00
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
2020-02-17 22:35:43 +01:00
# Replace the broken bin/slack symlink with a startup wrapper
rm $out/bin/slack
makeWrapper $out/lib/slack/slack $out/bin/slack \
--prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
2021-06-23 16:32:48 +02:00
--prefix PATH : ${lib.makeBinPath [xdg-utils]}
2020-02-17 22:35:43 +01:00
# Fix the desktop link
substituteInPlace $out/share/applications/slack.desktop \
--replace /usr/bin/ $out/bin/ \
--replace /usr/share/ $out/share/
runHook postInstall
2020-02-17 22:35:43 +01:00
'';
};
darwin = stdenv.mkDerivation {
inherit pname version src meta;
2020-02-17 22:35:43 +01:00
2020-11-05 01:12:36 +01:00
passthru.updateScript = ./update.sh;
nativeBuildInputs = [ undmg ];
2020-02-17 22:35:43 +01:00
sourceRoot = "Slack.app";
2020-02-17 22:35:43 +01:00
installPhase = ''
runHook preInstall
mkdir -p $out/Applications/Slack.app
cp -R . $out/Applications/Slack.app
2020-07-01 03:06:10 +02:00
/usr/bin/defaults write com.tinyspeck.slackmacgap SlackNoAutoUpdates -bool YES
runHook postInstall
2020-02-17 22:35:43 +01:00
'';
2016-03-22 21:05:02 +01:00
};
2021-06-23 16:32:48 +02:00
in
if stdenv.isDarwin
then darwin
else linux