Jump to content

Discord: Difference between revisions

From Official NixOS Wiki
imported>Artturin
category and troubleshooting
Sandro (talk | contribs)
Properly install systemd service
 
(40 intermediate revisions by 24 users not shown)
Line 1: Line 1:
{{unfree}}
{{Infobox application
| name = Discord
| type = instant messaging and VoIP social platform
| image = Discord-Symbol-Blurple.svg
| developer = Discord Inc.
| website = https://discord.com/
| platform = Cross-platform (Linux, macOS, Windows, Web)
| github = https://github.com/discord
}}
 
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 ==
== Installation ==
available builds
{{tip/unfree}}
<nowiki>
 
discord
=== Official Clients ===
discord-ptb
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">
discord-canary</nowiki>
# configuration.nix
replace the <code>discord</code> below with whichever build you want
{ config, lib, pkgs, ... }: {
=== NixOS ===
  # This will install Discord PTB for all users of the system
  environment.systemPackages = with pkgs; [
    discord-ptb
  ];


<syntaxhighlight lang="nix">
  # This installs Discord PTB only for the user "alice"
nixpkgs.config = {
  users.users.alice.packages = with pkgs; [
  allowUnfree = true;
    discord-ptb
};
  ];
environment.systemPackages = with pkgs; [ discord ]
}
</syntaxhighlight>
</syntaxhighlight>


=== Home Manager ===
=== Unofficial Clients ===
Can be used on both NixOS and non-NixOS
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 [https://discord.com/terms TOS], and can result in your account being permanently suspended from the platform!}}


Same as above but replace <code>environment.systemPackages</code> with <code>home.packages</code>
==== Legcord (formerly ArmCord)<ref>https://github.com/Legcord/Legcord</ref> ====
Lightweight, alternative desktop client with built-in modding extensibility. Nixpkgs provides this client via <code>pkgs.legcord</code>.<syntaxhighlight lang="nixos">
{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    legcord
  ];
}
</syntaxhighlight>


=== Non-NixOS ===
==== BetterDiscord<ref>https://betterdiscord.app/</ref> ====
[https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management declarative package management on non-nixos]
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


== Usage ==
$ nix-shell -p betterdiscordctl --command 'betterdiscordctl self-upgrade' # nix-legacy
Command Line:
$ nix run nixpkgs#betterdiscordctl -- self-upgrade # nix3
</syntaxhighlight>


<syntaxhighlight lang="console">
==== OpenAsar<ref>https://github.com/GooseMod/OpenAsar</ref> ====
$ Discord
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>
</syntaxhighlight>


The nix expression also installs a desktop item as another option for starting the application.
==== Vencord<ref>https://vencord.dev/</ref> ====
The cutest Discord client mod. The standalone Vencord client can be installed by overriding the official Discord package via <code>withVencord = true</code>.
{{File|3={ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    (discord.override {
      # withOpenASAR = true; # can do this here too
      withVencord = true;
    })
  ];
}|name=/etc/nixos/configuration.nix|lang=nix}}
 
==== Vesktop<ref>https://github.com/Vencord/Vesktop</ref> ====
As opposed to just Vencord, the same developers also offer an integrated solution which aims to make the Linux experience better.
 
It can be neatly managed via [[Home Manager]], or just installed as a regular package via <code>pkgs.vesktop</code>.
{{File|3={ config, lib, pkgs, ... }: {
  ...
  programs.vesktop = {
    enable = true;


== Join the NixOS Discord ==
    vencord.settings = {
      autoUpdate = true;
      autoUpdateNotification = true;
      notifyAboutUpdates = true;


Follow this link to join the unofficial NixOS Discord: https://discord.com/invite/RbvHtGa
      plugins = {
        ClearURLs.enabled = true;
        FixYoutubeEmbeds.enabled = true;
      };
    };
  };
  ...
}|name=home.nix|lang=nix}}
 
==== Webcord<ref>https://github.com/SpacingBat3/WebCord</ref> ====
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">
{ config, lib, pkgs, ... }: {
  environment.systemPackages = with pkgs; [
    webcord
  ];
}
</syntaxhighlight>


== Troubleshooting ==
== Troubleshooting ==


=== Discord crashes when a notification is received ===
=== Screen sharing on Wayland ===
Discord crashes if there is no notification daemon
Since December 2024, Discord Canary supports screen sharing on Wayland. Alternatively, you can use the web version on a browser that supports screen sharing on Wayland, or 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!}}


; Standalone notification daemons
=== Notifications causing crashes ===
; [https://github.com/dunst-project/dunst dunst]: for x11
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">
; [https://github.com/emersion/mako/ mako]: for wayland
{ 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>


=== Opening Links with Firefox ===
=== "Must be your lucky day" popup ===
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:
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>.
{{File|~/.config/discord/settings.json|json|
{
  "SKIP_HOST_UPDATE": true
<nowiki>}</nowiki>
}}


First, find out which NSS version Firefox is currently using with
=== Krisp noise suppression ===
<syntaxhighlight lang="console">
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.
$ nix path-info $(which firefox) -r | grep nss-
</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:
==== Python Script Workaround ====
<syntaxhighlight lang="nix">
{{Warning|The usage of such modifications goes against Discord's [https://discord.com/terms Terms of Service] and  Krisp's [https://krisp.ai/terms-of-use/ Terms of Use] and can result in your Discord account being terminated and/or being banned from using Krisp's services!}}
with import <nixpkgs> {};


pkgs.discord.override {
One way to enable Krisp noise suppression is by patching the <code>discord_krisp.node</code> binary to bypass its DRM verification. Below is a Nix configuration that creates a Python script that patches the binary by modifying specific bytes to bypass the license check: <syntaxhighlight lang="nixos">{ pkgs, ... }:
    nss = pkgs.nss_3_49_2;
let
  krisp-patcher =
    pkgs.writers.writePython3Bin "krisp-patcher"
      {
        libraries = with pkgs.python3Packages; [
          capstone
          pyelftools
        ];
        flakeIgnore = [
          "E501" # line too long (82 > 79 characters)
          "F403" # 'from module import *' used; unable to detect undefined names
          "F405" # name may be undefined, or defined from star imports: module
        ];
      }
      (
        builtins.readFile (
          pkgs.fetchurl {
            url = "https://pastebin.com/raw/8tQDsMVd";
            sha256 = "sha256-IdXv0MfRG1/1pAAwHLS2+1NESFEz2uXrbSdvU9OvdJ8=";
          }
        )
      );
in
{
  environment.systemPackages = [
    krisp-patcher
  ];
}
}
</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://search.nixos.org/packages/?query=nss_ here]. Finally, build and install this patched package with
{{Note|As of version 0.0.76, the script works. But, future versions of Discord may break the script. Therefore, you should not rely on this script for long-term use. For the latest updates and more details, follow https://github.com/NixOS/nixpkgs/issues/195512.}}
<syntaxhighlight lang="console">
 
$ nix-env -i $(nix build discord_patched.nix) --arg config '{ allowUnfree = true; }'
After adding this to your Nix configuration and rebuilding, make sure Discord is completely closed, and then run:
<pre>$ krisp-patcher ~/.config/discord/0.0.76/modules/discord_krisp/discord_krisp.node</pre>
 
Once you restart Discord and join a VC, you should see a sound wave icon to the left of the hangup icon.
 
=== 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]]
[[Category:Gaming]]


Log in again and you should be able to open links properly.
=== Discord RPC not functioning ===
== Links ==
[https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/discord/default.nix default.nix for discord]


==== NixOS ====
Install [https://github.com/OpenAsar/arrpc arRPC]:
<syntaxhighlight lang="nixos">
{pkgs, ...}:{
  enviroment.systemPackages = with pkgs; [
    arrpc
  ];
  systemd.packages = with pkgs; [ arrpc ];
}
</syntaxhighlight>


[[Category:Applications]]
==== Home Manager ====
Add the following to your Home Manager configuration
<syntaxhighlight lang="nixos">
{pkgs, ...}:{
    services.arrpc = {
        enable = true;
        package = pkgs.arrpc; #Default
        systemdTarget = "graphical-session.target"; #Default
    };
}
</syntaxhighlight>

Latest revision as of 09:53, 18 January 2026

Discord

instant messaging and VoIP social platform Application

100%
Developer(s)Discord Inc.
Platform(s)Cross-platform (Linux, macOS, Windows, Web)
External links
Websitehttps://discord.com/
GitHubhttps://github.com/discord

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

🟆︎
Tip: This package is unfree, and will require extra steps to install. You can read more about allowing unfree software in the Nixpkgs Manual.

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. The standalone Vencord client can be installed by overriding the official Discord package via withVencord = true.

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

Vesktop[5]

As opposed to just Vencord, the same developers also offer an integrated solution which aims to make the Linux experience better.

It can be neatly managed via Home Manager, or just installed as a regular package via pkgs.vesktop.

❄︎ home.nix
{ config, lib, pkgs, ... }: {
  ...
  programs.vesktop = {
    enable = true;

    vencord.settings = {
      autoUpdate = true;
      autoUpdateNotification = true;
      notifyAboutUpdates = true;

      plugins = {
        ClearURLs.enabled = true;
        FixYoutubeEmbeds.enabled = true;
      };
    };
  };
  ...
}

Webcord[6]

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

Screen sharing on Wayland

Since December 2024, Discord Canary supports screen sharing on Wayland. Alternatively, you can use the web version on a browser that supports screen sharing on Wayland, or 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.

Python Script Workaround

⚠︎
Warning: The usage of such modifications goes against Discord's Terms of Service and Krisp's Terms of Use and can result in your Discord account being terminated and/or being banned from using Krisp's services!

One way to enable Krisp noise suppression is by patching the discord_krisp.node binary to bypass its DRM verification. Below is a Nix configuration that creates a Python script that patches the binary by modifying specific bytes to bypass the license check:

{ pkgs, ... }:
let
  krisp-patcher =
    pkgs.writers.writePython3Bin "krisp-patcher"
      {
        libraries = with pkgs.python3Packages; [
          capstone
          pyelftools
        ];
        flakeIgnore = [
          "E501" # line too long (82 > 79 characters)
          "F403" # 'from module import *' used; unable to detect undefined names
          "F405" # name may be undefined, or defined from star imports: module
        ];
      }
      (
        builtins.readFile (
          pkgs.fetchurl {
            url = "https://pastebin.com/raw/8tQDsMVd";
            sha256 = "sha256-IdXv0MfRG1/1pAAwHLS2+1NESFEz2uXrbSdvU9OvdJ8=";
          }
        )
      );
in
{
  environment.systemPackages = [
    krisp-patcher
  ];
}
Note: As of version 0.0.76, the script works. But, future versions of Discord may break the script. Therefore, you should not rely on this script for long-term use. For the latest updates and more details, follow https://github.com/NixOS/nixpkgs/issues/195512.

After adding this to your Nix configuration and rebuilding, make sure Discord is completely closed, and then run:

$ krisp-patcher ~/.config/discord/0.0.76/modules/discord_krisp/discord_krisp.node

Once you restart Discord and join a VC, you should see a sound wave icon to the left of the hangup icon.

Text-to-Speech

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

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

Discord RPC not functioning

NixOS

Install arRPC:

{pkgs, ...}:{
  enviroment.systemPackages = with pkgs; [
    arrpc
  ];
  systemd.packages = with pkgs; [ arrpc ];
}

Home Manager

Add the following to your Home Manager configuration

{pkgs, ...}:{
    services.arrpc = {
        enable = true;
        package = pkgs.arrpc; #Default
        systemdTarget = "graphical-session.target"; #Default
    };
}