Discord: Difference between revisions

From NixOS Wiki
imported>Elitelinuxuser
m Added the installation commands for the non stable versions of discord as well.
Frontear (talk | contribs)
improve the troubleshooting format
 
(37 intermediate revisions by 21 users not shown)
Line 1: Line 1:
{{unfree}}
Discord is an instant messaging and VoIP application with lots of functionality. It provides a web interface, though most users would prefer to use a client for interoperability with their system.
== Install ==


To install discord directly in your environment without changing any configuration:
== Installation ==
{{Unfree}}


Stable:
=== Official Clients ===
<syntaxhighlight lang="console">
Nixpkgs provides all three of Discord's release channels, accessible as <code>pkgs.discord</code>, <code>pkgs.discord-ptb</code>, and <code>pkgs.discord-canary</code> respectively. Add any of the previous derivations to your package's configuration. For [[NixOS]] this will be in <code>environment.systemPackages</code> or <code>users.users.<name>.packages</code>.<syntaxhighlight lang="nixos">
$ nix-env -i discord --arg config '{ allowUnfree = true; }'
# configuration.nix
{ config, lib, pkgs, ... }: {
  # This will install Discord PTB for all users of the system
  environment.systemPackages = with pkgs; [
    discord-ptb
  ];
 
  # This installs Discord PTB only for the user "alice"
  users.users.alice.packages = with pkgs; [
    discord-ptb
  ];
}
</syntaxhighlight>
</syntaxhighlight>


Testing:
=== Unofficial Clients ===
<syntaxhighlight lang="console">
Nixpkgs also provides a vast variety of community developed/modded Discord clients, which can usually serve as drop-in replacements for the official discord client with an extended set of features.
$ nix-env -i discord-ptb --arg config '{ allowUnfree = true; }'
{{Warning|The usage of such client's goes against Discord's [https://discord.com/terms TOS], and can result in your account being permanently suspended from the platform!}}
</syntaxhighlight>
 
Nightly:
==== Legcord (formerly ArmCord)<ref>https://github.com/Legcord/Legcord</ref> ====
<syntaxhighlight lang="console">
Lightweight, alternative desktop client with built-in modding extensibility. Nixpkgs provides this client via <code>pkgs.legcord</code>.<syntaxhighlight lang="nixos">
$ nix-env -i discord-canary --arg config '{ allowUnfree = true; }'
{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    legcord
  ];
}
</syntaxhighlight>
</syntaxhighlight>


== Usage ==
==== BetterDiscord<ref>https://betterdiscord.app/</ref> ====
Command Line:
Enhances Discord desktop app with new features. Nixpkgs provides the installer via <code>pkgs.betterdiscordctl</code>. This can be added to your configuration, though users may prefer to instead run it one-off via the [[Nix]] cli.<syntaxhighlight lang="bash">
$ nix-shell -p betterdiscordctl --command 'betterdiscordctl install' # nix-legacy
$ nix run nixpkgs#betterdiscordctl -- install # nix3


<syntaxhighlight lang="console">
$ nix-shell -p betterdiscordctl --command 'betterdiscordctl self-upgrade' # nix-legacy
$ Discord
$ nix run nixpkgs#betterdiscordctl -- self-upgrade # nix3
</syntaxhighlight>
</syntaxhighlight>


The nix expression also installs a desktop item as another option for starting the application.
==== OpenAsar<ref>https://github.com/GooseMod/OpenAsar</ref> ====
Open-source alternative to Discord's <code>app.asar</code>. Nixpkgs provides this via <code>pkgs.openasar</code>, though this doesn't provide a usable client. Users should instead prefer overriding the official discord package and add <code>withOpenASAR = true</code>.<syntaxhighlight lang="nixos">
{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    (discord.override {
      withOpenASAR = true;
      # withVencord = true; # can do this here too
    })
  ];
}
</syntaxhighlight>


== Opening Links with Firefox ==
==== Vencord<ref>https://vencord.dev/</ref> ====
If you use Discord and it silently fails to open links in Firefox, you possibly have encountered [https://github.com/NixOS/nixpkgs/issues/78961 issue #78961]. This is caused by a version mismatch between the NSS libraries used by Discord and Firefox. Luckily, a relatively easy workaround is available:
The cutest Discord client mod. Nixpkgs provides their custom client [https://github.com/Vencord/Vesktop Vesktop] via<code>pkgs.vesktop</code>, or as an override for the official discord package via <code>withVencord = true</code>.<syntaxhighlight lang="nixos">
{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    # vesktop # If you prefer this


First, find out which NSS version Firefox is currently using with
    (discord.override {
<syntaxhighlight lang="console">
      # withOpenASAR = true; # can do this here too
$ nix path-info $(which firefox) -r | grep nss-
      withVencord = true;
    })
  ];
}
</syntaxhighlight>
</syntaxhighlight>


This should print a few store paths, focus on their ends, which should look like <code>nss-x.xx</code>. We're interested in the one with the newest version. Next, create a new file called <code>discord_patched.nix</code> and paste the following code into it:
==== Webcord<ref>https://github.com/SpacingBat3/WebCord</ref> ====
<syntaxhighlight lang="nix">
Discord and [https://spacebar.chat/ Spacebar] client implemented without using the official Discord API. Nixpkgs provides this client via <code>pkgs.webcord</code>.<syntaxhighlight lang="nixos">
with import <nixpkgs> {};
{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    webcord
  ];
}
</syntaxhighlight>
 
== Troubleshooting ==
 
=== Screensharing on Wayland ===
Discord's screen sharing capabilities have been broken for [https://support.discord.com/hc/en-us/community/posts/360047644231-Native-Wayland-Support?page=2#comments 5 years with no official fix]. The most consistent fix involves using the web version of Discord alongside a browser that supports screen sharing in Wayland, like [[Firefox]]. Alternatively, you can use an [[Discord#Unofficial Clients|unofficial client]] like ''Webcord'' or ''Vesktop'', both of which have fixed this issue in their own ways.
{{Note|Remember to configure an [https://wiki.archlinux.org/title/XDG_Desktop_Portal#List_of_backends_and_interfaces XDG Desktop Portal] with screen cast capabilities!}}


pkgs.discord.override {
=== Notifications causing crashes ===
    nss = pkgs.nss_3_49_2;
Discord will crash if there is no compatible notification daemon running. This issue is only prevalent in custom desktop environments, such as [[Sway]] or [[Hyprland]]. Comprehensive documentation usually exists for most window managers/compositors and can be found on their respective wikis. Nixpkgs provides a few standalone notification daemons such as <code>pkgs.dunst</code> and <code>pkgs.mako</code>. You may optionally use a notification daemon from a larger DE, such as <code>pkgs.lxqt.lxqt-notificationd</code>, however it is unclear how effective these will be outside of their normal environment.<syntaxhighlight lang="nixos">
{ config, lib, pkgs, ... }: {
  # You will need to add a call for the daemon to actually function.
  # This is usually done within the configuration of your respective WM.
  # See the official wiki/documentation for your WM for more info.
  environment.systemPackages = with pkgs; [
    mako
  ];
}
}
</syntaxhighlight>
</syntaxhighlight>


Now replace <code>nss_3_49_2</code> with the previously looked up version's "attribute name", which you can look up [https://nixos.org/nixos/packages.html?query=nss_ here]. Finally, build and install this patched package with
=== "Must be your lucky day" popup ===
<syntaxhighlight lang="console">
Although Nixpkgs is usually very fast with updates (if you use ''nixos-unstable''), you may still run into this issue intermittently. You may override the discord package with a more up-to-date source, or you may disable this popup entirely by adding <code>"SKIP_HOST_UPDATE": true</code> to <code>~/.config/discord/settings.json</code>.
$ nix-env -i $(nix build discord_patched.nix) --arg config '{ allowUnfree = true; }'
{{File|~/.config/discord/settings.json|json|
{
  "SKIP_HOST_UPDATE": true
<nowiki>}</nowiki>
}}
 
=== Krisp noise suppression ===
The Krisp noise suppression option will not work on NixOS because the Discord binary is patched before installation, and there is a DRM-style integrity check in the Krisp binary which prevents Krisp from working if the Discord binary is modified. See https://github.com/NixOS/nixpkgs/issues/195512 for details.
 
=== Text-to-Speech ===
TTS is disabled by default; you may enable it via an override:
<syntaxhighlight lang="nix">
(pkgs.discord.override { withTTS = true; })
</syntaxhighlight>
</syntaxhighlight>
 
[[Category:Applications]]
Log in again and you should be able to open links properly.
[[Category:Gaming]]
== Links ==
[https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/discord/default.nix default.nix for discord]

Latest revision as of 00:33, 18 October 2024

Discord is an instant messaging and VoIP application with lots of functionality. It provides a web interface, though most users would prefer to use a client for interoperability with their system.

Installation

Note: This package is unfree and requires extra steps to install.

Official Clients

Nixpkgs provides all three of Discord's release channels, accessible as pkgs.discord, pkgs.discord-ptb, and pkgs.discord-canary respectively. Add any of the previous derivations to your package's configuration. For NixOS this will be in environment.systemPackages or users.users.<name>.packages.

# configuration.nix
{ config, lib, pkgs, ... }: {
  # This will install Discord PTB for all users of the system
  environment.systemPackages = with pkgs; [
    discord-ptb
  ];

  # This installs Discord PTB only for the user "alice"
  users.users.alice.packages = with pkgs; [
    discord-ptb
  ];
}

Unofficial Clients

Nixpkgs also provides a vast variety of community developed/modded Discord clients, which can usually serve as drop-in replacements for the official discord client with an extended set of features.

Warning: The usage of such client's goes against Discord's TOS, and can result in your account being permanently suspended from the platform!

Legcord (formerly ArmCord)[1]

Lightweight, alternative desktop client with built-in modding extensibility. Nixpkgs provides this client via pkgs.legcord.

{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    legcord
  ];
}

BetterDiscord[2]

Enhances Discord desktop app with new features. Nixpkgs provides the installer via pkgs.betterdiscordctl. This can be added to your configuration, though users may prefer to instead run it one-off via the Nix cli.

$ nix-shell -p betterdiscordctl --command 'betterdiscordctl install' # nix-legacy
$ nix run nixpkgs#betterdiscordctl -- install # nix3

$ nix-shell -p betterdiscordctl --command 'betterdiscordctl self-upgrade' # nix-legacy
$ nix run nixpkgs#betterdiscordctl -- self-upgrade # nix3

OpenAsar[3]

Open-source alternative to Discord's app.asar. Nixpkgs provides this via pkgs.openasar, though this doesn't provide a usable client. Users should instead prefer overriding the official discord package and add withOpenASAR = true.

{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    (discord.override {
      withOpenASAR = true;
      # withVencord = true; # can do this here too
    })
  ];
}

Vencord[4]

The cutest Discord client mod. Nixpkgs provides their custom client Vesktop viapkgs.vesktop, or as an override for the official discord package via withVencord = true.

{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    # vesktop # If you prefer this

    (discord.override {
      # withOpenASAR = true; # can do this here too
      withVencord = true;
    })
  ];
}

Webcord[5]

Discord and Spacebar client implemented without using the official Discord API. Nixpkgs provides this client via pkgs.webcord.

{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    webcord
  ];
}

Troubleshooting

Screensharing on Wayland

Discord's screen sharing capabilities have been broken for 5 years with no official fix. The most consistent fix involves using the web version of Discord alongside a browser that supports screen sharing in Wayland, like Firefox. Alternatively, you can use an unofficial client like Webcord or Vesktop, both of which have fixed this issue in their own ways.

Note: Remember to configure an XDG Desktop Portal with screen cast capabilities!

Notifications causing crashes

Discord will crash if there is no compatible notification daemon running. This issue is only prevalent in custom desktop environments, such as Sway or Hyprland. Comprehensive documentation usually exists for most window managers/compositors and can be found on their respective wikis. Nixpkgs provides a few standalone notification daemons such as pkgs.dunst and pkgs.mako. You may optionally use a notification daemon from a larger DE, such as pkgs.lxqt.lxqt-notificationd, however it is unclear how effective these will be outside of their normal environment.

{ config, lib, pkgs, ... }: {
  # You will need to add a call for the daemon to actually function.
  # This is usually done within the configuration of your respective WM.
  # See the official wiki/documentation for your WM for more info.
  environment.systemPackages = with pkgs; [
    mako
  ];
}

"Must be your lucky day" popup

Although Nixpkgs is usually very fast with updates (if you use nixos-unstable), you may still run into this issue intermittently. You may override the discord package with a more up-to-date source, or you may disable this popup entirely by adding "SKIP_HOST_UPDATE": true to ~/.config/discord/settings.json.

~/.config/discord/settings.json
{
  "SKIP_HOST_UPDATE": true
}

Krisp noise suppression

The Krisp noise suppression option will not work on NixOS because the Discord binary is patched before installation, and there is a DRM-style integrity check in the Krisp binary which prevents Krisp from working if the Discord binary is modified. See https://github.com/NixOS/nixpkgs/issues/195512 for details.

Text-to-Speech

TTS is disabled by default; you may enable it via an override:

(pkgs.discord.override { withTTS = true; })