Difference between revisions of "Discord"

From NixOS Wiki
Jump to: navigation, search
m (fix syntax in example)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(24 intermediate revisions by 15 users not shown)
Line 2: Line 2:
  
 
== Installation ==
 
== Installation ==
available builds
+
Add one of
<nowiki>
 
discord
 
discord-ptb
 
discord-canary</nowiki>
 
replace the <code>discord</code> below with whichever build you want
 
=== NixOS ===
 
  
 +
<pre>
 +
pkgs.discord
 +
pkgs.discord-ptb
 +
pkgs.discord-canary
 +
</pre>
 +
 +
to your <code>environment.systemPackages</code> (NixOS) or <code>home.packages</code> (Home Manager).
 +
 +
Additionally, see [[Unfree Software]] to allow Discord to be installed.
 +
 +
== Alternative packages ==
 +
 +
=== BetterDiscord ===
 +
[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].
 +
<syntaxhighlight lang="console">
 +
$ nix run nixpkgs#betterdiscordctl install
 +
</syntaxhighlight>
 +
 +
=== OpenAsar / Vencord ===
 +
 +
Discord has to be launched once without modifications, maybe every update, otherwise there will be a <code>MODULE_NOT_FOUND</code> error. See [https://github.com/NixOS/nixpkgs/issues/208749 #208749]
 +
 +
You can use Discord [https://github.com/GooseMod/OpenAsar OpenAsar] and/or [https://github.com/Vendicated/Vencord Vencord] by replacing <code>pkgs.discord</code> (or any other discord package) in your list of packages with the following override:
 
<syntaxhighlight lang="nix">
 
<syntaxhighlight lang="nix">
nixpkgs.config = {
+
(pkgs.discord.override {
   allowUnfree = true;
+
   # remove any overrides that you don't want
};
+
  withOpenASAR = true;
environment.systemPackages = with pkgs; [ discord ]
+
  withVencord = true;
 +
})
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Home Manager ===
+
{{ warning | Do not remove the parentheses, or it will not work. }}
Can be used on both NixOS and non-NixOS
 
  
Same as above but replace <code>environment.systemPackages</code> with <code>home.packages</code>
+
=== Screensharing with audio on wayland ===
  
=== Non-NixOS ===
+
==== Vesktop ====
[https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management declarative package management on non-nixos]
 
  
== Usage ==
+
Screen sharing with audio is achievable using `pkgs.Vesktop`. To enable this feature, include it in the system packages as follows:
Command Line:
 
  
<syntaxhighlight lang="console">
+
<syntaxhighlight lang="nix">
$ Discord
+
environment.systemPackages = [
 +
    pkgs.vesktop
 +
];
 
</syntaxhighlight>
 
</syntaxhighlight>
  
The nix expression also installs a desktop item as another option for starting the application.
+
Then, execute it using `vesktop`.
 +
 
  
 
== Join the NixOS Discord ==
 
== Join the NixOS Discord ==
Line 41: Line 59:
  
 
=== Discord crashes when a notification is received ===
 
=== Discord crashes when a notification is received ===
Discord crashes if there is no notification daemon
+
Discord crashes if there is no notification-daemon
  
 
standalone notification daemons  
 
standalone notification daemons  
Line 51: Line 69:
 
[[File:discord_update_latest.png]]
 
[[File:discord_update_latest.png]]
  
Discord refuses to start because they have released an update and only the latest version can connect to their service.
+
Discord refuses to start because they have released an update and it wants to download that instead.
 +
 
 +
To prevent Discord from checking for new versions, add the following to <code>~/.config/discord/settings.json</code>:
 +
<syntaxhighlight lang="json">
 +
{
 +
    "SKIP_HOST_UPDATE": true
 +
}</syntaxhighlight>
 +
If the file already exists the braces aren't necessary.
 +
 
 +
 
 +
Alternatively, you can install the updated version.
  
Most of the time this is a temporary problem, and you can just wait for the version to be bumped in nixpkgs and update then.
+
If the version has already been updated in a newer version of nixpkgs, installing it works something like this:
For the impatient the workaround is something like this:
 
  
 
<syntaxhighlight lang="nix">
 
<syntaxhighlight lang="nix">
Line 62: Line 89:
 
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]
 
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]
  
If it was fixed in master, the other alternatives are:
+
If it was fixed in master, the other alternatives are:
  
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
Line 93: Line 120:
 
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
 
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">
 
<syntaxhighlight lang="console">
$ nix-env -i $(nix build discord_patched.nix) --arg config '{ allowUnfree = true; }'
+
$ 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.
 
Log in again and you should be able to open links properly.
 +
 +
=== 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>
 +
 
== Links ==
 
== Links ==
 
[https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/discord/default.nix default.nix for discord]
 
[https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/discord/default.nix default.nix for discord]

Latest revision as of 10:56, 6 April 2024

Note: This package is unfree. Read the FAQ entry to know how to use unfree packages.

Installation

Add one of

pkgs.discord
pkgs.discord-ptb
pkgs.discord-canary

to your environment.systemPackages (NixOS) or home.packages (Home Manager).

Additionally, see Unfree Software to allow Discord to be installed.

Alternative packages

BetterDiscord

BetterDiscord is a client modification engine which allows you to use custom plugins, themes, and more. The easiest way to install this is using betterdiscordctl.

$ nix run nixpkgs#betterdiscordctl install

OpenAsar / Vencord

Discord has to be launched once without modifications, maybe every update, otherwise there will be a MODULE_NOT_FOUND error. See #208749

You can use Discord OpenAsar and/or Vencord by replacing pkgs.discord (or any other discord package) in your list of packages with the following override:

(pkgs.discord.override {
  # remove any overrides that you don't want
  withOpenASAR = true;
  withVencord = true;
})
Warning: Do not remove the parentheses, or it will not work.

Screensharing with audio on wayland

Vesktop

Screen sharing with audio is achievable using `pkgs.Vesktop`. To enable this feature, include it in the system packages as follows:

environment.systemPackages = [
    pkgs.vesktop
];

Then, execute it using `vesktop`.


Join the NixOS Discord

Follow this link to join the unofficial NixOS Discord: https://discord.com/invite/RbvHtGa

Troubleshooting

Discord crashes when a notification is received

Discord crashes if there is no notification-daemon

standalone notification daemons

  • dunst — Lightweight and customizable notification daemon for x11
https://github.com/dunst-project/dunst || dunst
  • mako — A lightweight Wayland notification daemon
https://github.com/emersion/mako/ || mako

Discord wants latest version

Discord update latest.png

Discord refuses to start because they have released an update and it wants to download that instead.

To prevent Discord from checking for new versions, add the following to ~/.config/discord/settings.json:

{
    "SKIP_HOST_UPDATE": true
}

If the file already exists the braces aren't necessary.


Alternatively, you can install the updated version.

If the version has already been updated in a newer version of nixpkgs, installing it works something like this:

nixpkgs.overlays = [(self: super: { discord = super.discord.overrideAttrs (_: { src = builtins.fetchTarball <link-to-tarball>; });})];

An overlay to build discord manually from the URL to the latest tarball on [1], see [2]

If it was fixed in master, the other alternatives are:

nix-env -f https://github.com/NixOS/nixpkgs/archive/release-20.09.tar.gz -iA discord

or with nix-shell:

NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/release-20.09.tar.gz nix-shell -p discord --run Discord

Opening Links with Firefox

If you use Discord and it silently fails to open links in Firefox, you possibly have encountered 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

$ nix path-info $(which firefox) -r | grep nss-

This should print a few store paths, focus on their ends, which should look like nss-x.xx. We're interested in the one with the newest version. Next, create a new file called discord_patched.nix and paste the following code into it:

with import <nixpkgs> {};

pkgs.discord.override {
    nss = pkgs.nss_3_49_2;
}

Now replace nss_3_49_2 with the previously looked up version's "attribute name", which you can look up here. Finally, build and install this patched package with

$ export NIXPKGS_ALLOW_UNFREE=1; nix-env -i $(nix-build discord_patched.nix) --arg config '{ allowUnfree = true; }'

Log in again and you should be able to open links properly.

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; })

Links

default.nix for discord