Slack

From NixOS Wiki
Revision as of 20:28, 16 November 2021 by imported>Patryk27

Slack is a communication platform with a desktop application based on Electron.

Installation

NixOS

environment.systemPackages = with pkgs; [ slack ];

Non-NixOS

$ nix-env -iA nixos.slack

Tips

Wayland

Since Electron's support for Wayland is of somewhat beta-quality, by default Slack will run through Xwayland, making it hard to do screen-sharing or use it comfortably on 4k+ screens - fortunately, it's possible to run it natively by specifying a few parameters:

$ slack --ozone-platform=wayland --enable-features=UseOzonePlatform,WebRTCPipeWireCapturer

... or, which is a bit more convenient, by patching the derivation:

{ lib, pkgs, ... }:
let
  slack = pkgs.slack.overrideAttrs (old: {
    installPhase = old.installPhase + ''
      rm $out/bin/slack

      makeWrapper $out/lib/slack/slack $out/bin/slack \
        --prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
        --prefix PATH : ${lib.makeBinPath [pkgs.xdg-utils]} \
        --add-flags "--ozone-platform=wayland --enable-features=UseOzonePlatform,WebRTCPipeWireCapturer"
    '';
  });

in
{
  environment.systemPackages = [ slack ];
}

In either of the cases, if you want to use screen-sharing, you'll have to enable xdg-desktop-portal, too:

xdg = {
  portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-wlr
      xdg-desktop-portal-gtk
    ];
    gtkUsePortal = true;
  };
};