Slack: Difference between revisions

From NixOS Wiki
imported>Mic92
No edit summary
imported>Patryk27
No edit summary
Line 1: Line 1:
'''How to Install the Slack chat client'''
[https://slack.com/ Slack] is a communication platform with a desktop application based on Electron.


To install the chat client, do:
== Installation ==


<syntaxHighlight lang=console>
=== NixOS ===
 
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [ slack ];
</syntaxhighlight>
 
=== Non-NixOS ===
 
<syntaxHighlight lang="console">
$ nix-env -iA nixos.slack
$ nix-env -iA nixos.slack
</syntaxHighlight>
</syntaxHighlight>


To launch or run the chat client, do
== Tips ==
 
=== Wayland ===


<syntaxHighlight lang=console>
Since Electron's support for Wayland is of somewhat beta-quality, by default Slack will run through Xwayland, making it hard to share-screen and use it comfortably on 4k+ screens - fortunately, it's possible to run it natively by specifying a few parameters:
$ slack
 
<syntaxHighlight lang="console">
$ slack --ozone-platform=wayland --enable-features=UseOzonePlatform,WebRTCPipeWireCapturer
</syntaxHighlight>
</syntaxHighlight>


And remember, because this is Nixos, you don't have to be root to install things. The above steps will install the Slack chat client as a non-root user.
... or, which is a bit more convenient, by patching the derivation:
 
<syntaxhighlight lang="nix">
{ 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 ];
}
</syntaxHighlight>
 
In either of the cases, if you want to use screen-sharing, you'll have to enable xdg-desktop-portal, too:
 
<syntaxhighlight lang="nix">
xdg = {
  portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-wlr
      xdg-desktop-portal-gtk
    ];
    gtkUsePortal = true;
  };
};
</syntaxhighlight>

Revision as of 20:26, 16 November 2021

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 share-screen and 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;
  };
};