Discord: Difference between revisions

imported>Hyperfekt
m format settings file path
Scrumplex (talk | contribs)
m Add information about Wayland screen sharing with Discord Canary
 
(25 intermediate revisions by 15 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.


== Installation ==
== Installation ==
available builds
{{Unfree}}
<nowiki>
discord
discord-ptb
discord-canary</nowiki>
replace the <code>discord</code> below with whichever build you want
=== NixOS ===


<syntaxhighlight lang="nix">
=== Official Clients ===
nixpkgs.config = {
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">
   allowUnfree = true;
# configuration.nix
};
{ config, lib, pkgs, ... }: {
environment.systemPackages = with pkgs; [ discord ]
   # 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>


=== 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. 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


=== Installing BetterDiscord ===
    (discord.override {
[https://betterdiscord.app BetterDiscord] is a client modification engine which allows you to use custom plugins, themes, and more. The easiest way to install this is using [https://github.com/bb010g/betterdiscordctl betterdiscordctl].
      # withOpenASAR = true; # can do this here too
<syntaxhighlight lang="console">
      withVencord = true;
$ nix run nixpkgs.betterdiscordctl -c betterdiscordctl install
    })
  ];
}
</syntaxhighlight>
</syntaxhighlight>


== Join the NixOS Discord ==
==== 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">
Follow this link to join the unofficial NixOS Discord: https://discord.com/invite/RbvHtGa
{ 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 ===
{{app|dunst|Lightweight and customizable notification daemon for x11|https://github.com/dunst-project/dunst|dunst}}
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">
{{app|mako|A lightweight Wayland notification daemon|https://github.com/emersion/mako/|mako}}
{ 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>


=== Discord wants latest version ===
=== "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 <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>
}}


[[File:discord_update_latest.png]]
=== 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.


Discord refuses to start because they have released an update and it wants to download that instead.
==== Python Script Workaround ====
{{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!}}


To prevent Discord from checking for new versions, add the following to <code>~/.config/discord/settings.json</code>:
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, ... }:
<syntaxhighlight lang="json">"SKIP_HOST_UPDATE": true</syntaxhighlight>
let
 
  krisp-patcher =
 
    pkgs.writers.writePython3Bin "krisp-patcher"
Alternatively, you can install the updated version.
      {
 
        libraries = with pkgs.python3Packages; [
If the version has already been updated in a newer version of nixpkgs, installing it works something like this:
          capstone
 
          pyelftools
<syntaxhighlight lang="nix">
        ];
nixpkgs.overlays = [(self: super: { discord = super.discord.overrideAttrs (_: { src = builtins.fetchTarball <link-to-tarball>; });})];
        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>


An overlay to build discord manually from the URL to the latest tarball on [https://discord.com/api/download?platform=linux&format=tar.gz], see [https://github.com/NixOS/nixpkgs/issues/94806]
{{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.}}


If it was fixed in master, the other alternatives are:
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>


<syntaxhighlight lang="console">
Once you restart Discord and join a VC, you should see a sound wave icon to the left of the hangup icon.
nix-env -f https://github.com/NixOS/nixpkgs/archive/release-20.09.tar.gz -iA discord
</syntaxhighlight>


or with nix-shell:
=== Text-to-Speech ===
 
TTS is disabled by default; you may enable it via an override:
<syntaxhighlight lang="console">
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/release-20.09.tar.gz nix-shell -p discord --run Discord
</syntaxhighlight>
 
=== Opening Links with Firefox ===
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:
 
First, find out which NSS version Firefox is currently using with
<syntaxhighlight lang="console">
$ 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:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
with import <nixpkgs> {};
(pkgs.discord.override { withTTS = true; })
 
pkgs.discord.override {
    nss = pkgs.nss_3_49_2;
}
</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
<syntaxhighlight lang="console">
$ export NIXPKGS_ALLOW_UNFREE=1; nix-env -i $(nix-build discord_patched.nix) --arg config '{ allowUnfree = true; }'
</syntaxhighlight>
</syntaxhighlight>
Log in again and you should be able to open links properly.
== Links ==
[https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/discord/default.nix default.nix for discord]
[[Category:Applications]]
[[Category:Applications]]
[[Category:Gaming]]