Discord: Difference between revisions

From NixOS Wiki
imported>Deingithub
m Add highlighting for command lines
imported>Deingithub
Add workaround for nixos/nixpkgs#78961
Line 17: Line 17:
The nix expression also installs a desktop item as another option for starting the application.
The nix expression also installs a desktop item as another option for starting the application.


== 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">
with import <nixpkgs> {};
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://nixos.org/nixos/packages.html?query=nss_ here]. Finally, build and install this patched package with
<syntaxhighlight lang="console">
$ nix-env -i $(nix build discord_patched.nix) --arg config '{ allowUnfree = true; }'
</syntaxhighlight>
Log in again and you should be able to open links properly.
== 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]

Revision as of 13:27, 25 April 2020

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

Install

To install discord directly in your environment without changing any configuration:

$ nix-env -i discord --arg config '{ allowUnfree = true; }'

Usage

Command Line:

$ Discord

The nix expression also installs a desktop item as another option for starting the application.

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

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

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

Links

default.nix for discord