Wayland compatible. In theory it should support pipewire screensharing but for whatever reason it dosen't seem to be working. :(
YTAPVEQTBGK2OP64KXW7QHKRYSXGNGQNNCP4ZZ3Q6VDPHCYQSGTAC
(self: super: {
discord = super.discord.overrideAttrs (_: {
src = builtins.fetchTarball {
url = "https://discordapp.com/api/download?platform=linux&format=tar.gz";
sha256 = "1ahj4bhdfd58jcqh54qcgafljqxl1747fqqwxhknqlasa83li75n";
final: prev: rec {
discord-canary-system = prev.callPackage mkDiscord (rec {
pname = "discord-canary";
version = "latest";
binaryName = "DiscordCanary";
desktopName = "Discord Canary";
src = final.discord-canary.src;
isWayland = true;
enableVulkan = false;
extraOptions = [
"--enable-vulkan"
"--ignore-gpu-blocklist"
"--enable-gpu-rasterization"
"--enable-zero-copy"
"--disable-gpu-driver-bug-workarounds"
];
});
mkDiscord =
{ pname
, version
, src
, binaryName
, desktopName
, isWayland ? false
, enableVulkan ? false
, extraOptions ? [ ]
, autoPatchelfHook
, makeDesktopItem
, lib
, stdenv
, wrapGAppsHook
, alsaLib
, at-spi2-atk
, at-spi2-core
, atk
, cairo
, cups
, dbus
, electron
, expat
, fontconfig
, freetype
, gdk-pixbuf
, glib
, gtk3
, libcxx
, libdrm
, libnotify
, libpulseaudio
, libuuid
, libX11
, libXScrnSaver
, libXcomposite
, libXcursor
, libXdamage
, libXext
, libXfixes
, libXi
, libXrandr
, libXrender
, libXtst
, libxcb
, mesa
, nspr
, nss
, pango
, systemd
, libappindicator-gtk3
, libdbusmenu
, nodePackages
, vulkan-loader
, vulkan-extension-layer
, libGL
}:
stdenv.mkDerivation rec {
inherit pname version src;
nativeBuildInputs = [
nodePackages.asar
alsaLib
autoPatchelfHook
cups
libdrm
libuuid
libXdamage
libX11
libXScrnSaver
libXtst
libxcb
mesa.drivers
nss
wrapGAppsHook
];
dontWrapGApps = true;
libPath = lib.makeLibraryPath [
libcxx
systemd
libpulseaudio
stdenv.cc.cc
alsaLib
atk
at-spi2-atk
at-spi2-core
cairo
cups
dbus
expat
fontconfig
freetype
gdk-pixbuf
glib
gtk3
libnotify
libX11
libXcomposite
libuuid
libXcursor
libXdamage
libXext
libXfixes
libXi
libXrandr
libXrender
libXtst
nspr
nss
libxcb
pango
systemd
libXScrnSaver
libappindicator-gtk3
libdbusmenu
vulkan-loader
vulkan-extension-layer
libGL
];
flags = (lib.optionals isWayland [
"--flag-switches-begin"
"--enable-features=UseOzonePlatform,WebRTCPipeWireCapturer${lib.optionalString enableVulkan ",Vulkan"}"
"--flag-switches-end"
"--ozone-platform=wayland"
"--enable-webrtc-pipewire-capturer"
]) ++ extraOptions;
installPhase = ''
mkdir -p $out/{bin,usr/lib/${pname},share/pixmaps}
ln -s discord.png $out/share/pixmaps/${pname}.png
ln -s "${desktopItem}/share/applications" $out/share/
# HACKS FOR SYSTEM ELECTRON
asar e resources/app.asar resources/app
rm resources/app.asar
sed -i "s|process.resourcesPath|'$out/usr/lib/${pname}'|" resources/app/app_bootstrap/buildInfo.js
sed -i "s|exeDir,|'$out/share/pixmaps',|" resources/app/app_bootstrap/autoStart/linux.js
asar p resources/app resources/app.asar --unpack-dir '**'
rm -rf resources/app
# Copy Relevanat data
cp -r resources/* $out/usr/lib/${pname}/
# Create starter script for discord
echo "#!${stdenv.shell}" > $out/bin/${pname}
echo "exec ${electron}/bin/electron ${lib.concatStringsSep " " flags} $out/usr/lib/${pname}/app.asar \$@" >> $out/bin/${pname}
chmod 755 $out/bin/${pname}
wrapProgram $out/bin/${pname} \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--prefix LD_LIBRARY_PATH : ${libPath}
'';
desktopItem = makeDesktopItem {
name = pname;
exec = pname;
icon = pname;
inherit desktopName;
genericName = meta.description;
categories = "Network;InstantMessaging;";
mimeType = "x-scheme-handler/discord";
};
meta = with lib; {
description = "All-in-one cross-platform voice and text chat for gamers";
homepage = "https://discordapp.com/";
downloadPage = "https://discordapp.com/download";
platforms = [ "x86_64-linux" ];
};