This commit is contained in:
dusk 2021-05-25 02:52:49 +03:00
parent 9136c273e1
commit 9c7e5d088a
Signed by: dusk
GPG Key ID: 1D8F8FAF2294D6EA
4 changed files with 216 additions and 7 deletions

View File

@ -206,11 +206,11 @@
},
"latest": {
"locked": {
"lastModified": 1621888382,
"narHash": "sha256-dGeE/SnWafRHmOC3KplwB27pJp1d1Ta1rj3VYIuBx58=",
"lastModified": 1621896249,
"narHash": "sha256-HuRgOz0bY78RrvM2rRPbTRaxHNBMl+sImnA2YfPN6ac=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d706be982af01d39a22fdea6a6d3cfe067909d77",
"rev": "7cb8324a9124b0ee38c97d690e90d1ac571d8c69",
"type": "github"
},
"original": {
@ -394,11 +394,11 @@
},
"nur": {
"locked": {
"lastModified": 1621886351,
"narHash": "sha256-5m5ZcOo8Yap2aoTU8BHBvY2zuiXve4J6T9M1qQpQf5w=",
"lastModified": 1621894950,
"narHash": "sha256-Rv8vxsa0bKrtazX5jEouxJNRi6ptcTov6+Q6+B3HDvc=",
"owner": "nix-community",
"repo": "NUR",
"rev": "cc939dfd4c098d96bcc0c96b89e69226ea80fb42",
"rev": "e606d718cb7d5444cba28aa17305831bd061135a",
"type": "github"
},
"original": {

View File

@ -0,0 +1,184 @@
final: prev: rec {
discord-canary-system = prev.callPackage mkDiscord (rec {
pname = "discord-canary";
version = "0.0.123";
binaryName = "DiscordCanary";
desktopName = "Discord Canary";
src = prev.fetchurl {
url = "https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
sha256 = "0bijwfsd9s4awqkgxd9c2cxh7y5r06vix98qjp0dkv63r6jig8ch";
};
isWayland = true;
extraOptions = [
"--enable-vulkan"
"--ignore-gpu-blocklist"
"--enable-gpu-rasterization"
"--enable-zero-copy"
];
});
mkDiscord =
{ pname
, version
, src
, binaryName
, desktopName
, isWayland ? 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
}:
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
];
flags = (lib.optionals isWayland [
"--enable-features=UseOzonePlatform"
"--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" ];
};
};
}

View File

@ -0,0 +1,25 @@
final: prev: {
discord-canary = prev.discord-canary.overrideAttrs (old:
let binaryName = "DiscordCanary"; in
rec {
version = "0.0.123";
src = prev.fetchurl {
url = "https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
sha256 = "0bijwfsd9s4awqkgxd9c2cxh7y5r06vix98qjp0dkv63r6jig8ch";
};
installPhase = ''
mkdir -p $out/{bin,opt/${binaryName},share/pixmaps}
mv * $out/opt/${binaryName}
chmod +x $out/opt/${binaryName}/${binaryName}
patchelf --set-interpreter ${prev.stdenv.cc.bintools.dynamicLinker} \
$out/opt/${binaryName}/${binaryName}
wrapProgram $out/opt/${binaryName}/${binaryName} \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${prev.gtk3}/share/gsettings-schemas/${prev.gtk3.name}/" \
--prefix LD_LIBRARY_PATH : "${old.libPath}:${prev.electron_9}/lib/electron:${prev.libdrm}/lib:${prev.libGL_driver.out}/lib"
ln -s $out/opt/${binaryName}/${binaryName} $out/bin/
ln -s $out/opt/${binaryName}/discord.png $out/share/pixmaps/${old.pname}.png
ln -s "${old.desktopItem}/share/applications" $out/share/
'';
});
}

View File

@ -335,7 +335,7 @@ in
font-awesome
(nerdfonts.override { fonts = [ "Iosevka" ]; })
# Programs
discord-canary
discord-canary-system
audacity
krita
gimp