discord-{ptb,canary}: init; add update-discord

This commit is contained in:
Tadeo Kondrak 2019-06-18 23:39:15 -06:00 committed by Cray Elliott
parent 0687a9d8db
commit e6f23b8b1e
4 changed files with 143 additions and 61 deletions

View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
# script to generate `pkgs/networking/instant-messengers/discord/default.nix`
set -e
exec >${1:?usage: $0 <output-file>}
cat <<EOF
{ branch ? "stable", pkgs }:
let
inherit (pkgs) callPackage fetchurl;
in {
EOF
for branch in "" ptb canary; do
url=$(curl -sI "https://discordapp.com/api/download${branch:+/}${branch}?platform=linux&format=tar.gz" | grep -oP 'location: \K\S+')
version=${url##https://dl*.discordapp.net/apps/linux/}
version=${version%%/*.tar.gz}
echo " ${branch:-stable} = callPackage ./base.nix {"
echo " pname = \"discord${branch:+-}${branch}\";"
case $branch in
"") suffix="" ;;
ptb) suffix="PTB" ;;
canary) suffix="Canary" ;;
esac
echo " binaryName = \"Discord${suffix}\";"
echo " desktopName = \"Discord${suffix:+ }${suffix}\";"
echo " version = \"${version}\";"
echo " src = fetchurl {"
echo " url = \"${url}\";"
echo " sha256 = \"$(nix-prefetch-url "$url")\";"
echo " };"
echo " };"
done
echo "}.\${branch}"

View File

@ -0,0 +1,61 @@
{ pname, version, src, binaryName, desktopName
, stdenv, fetchurl, makeDesktopItem, wrapGAppsHook
, alsaLib, atk, at-spi2-atk, at-spi2-core, cairo, cups, dbus, expat, fontconfig, freetype
, gdk_pixbuf, glib, gtk3, libnotify, libX11, libXcomposite, libXcursor, libXdamage, libuuid
, libXext, libXfixes, libXi, libXrandr, libXrender, libXtst, nspr, nss, libxcb
, pango, systemd, libXScrnSaver, libcxx, libpulseaudio }:
let
inherit binaryName;
in stdenv.mkDerivation rec {
inherit pname version src;
nativeBuildInputs = [ wrapGAppsHook ];
dontWrapGApps = true;
libPath = stdenv.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
];
installPhase = ''
mkdir -p $out/{bin,opt/${binaryName},share/pixmaps}
mv * $out/opt/${binaryName}
chmod +x $out/opt/${binaryName}/${binaryName}
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
$out/opt/${binaryName}/${binaryName}
wrapProgram $out/opt/${binaryName}/${binaryName} \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--prefix LD_LIBRARY_PATH : ${libPath}
ln -s $out/opt/${binaryName}/${binaryName} $out/bin/
ln -s $out/opt/${binaryName}/discord.png $out/share/pixmaps/${binaryName}.png
ln -s "${desktopItem}/share/applications" $out/share/
'';
desktopItem = makeDesktopItem {
name = pname;
exec = binaryName;
icon = pname;
inherit desktopName;
genericName = meta.description;
categories = "Network;InstantMessaging;";
};
meta = with stdenv.lib; {
description = "All-in-one cross-platform voice and text chat for gamers";
homepage = "https://discordapp.com/";
downloadPage = "https://discordapp.com/download";
license = licenses.unfree;
maintainers = with maintainers; [ ldesgoui MP2E tadeokondrak ];
platforms = [ "x86_64-linux" ];
};
}

View File

@ -1,64 +1,36 @@
{ stdenv, fetchurl, makeDesktopItem, wrapGAppsHook
, alsaLib, atk, at-spi2-atk, cairo, cups, dbus, expat, fontconfig, freetype, gdk_pixbuf
, glib, gtk3, libnotify, libX11, libXcomposite, libXcursor, libXdamage, libuuid
, libXext, libXfixes, libXi, libXrandr, libXrender, libXtst, nspr, nss, libxcb
, pango, systemd, libXScrnSaver, libcxx, libpulseaudio }:
{ branch ? "stable", pkgs }:
stdenv.mkDerivation rec {
pname = "discord";
version = "0.0.9";
src = fetchurl {
url = "https://cdn.discordapp.com/apps/linux/${version}/${pname}-${version}.tar.gz";
sha256 = "1i0f8id10rh2fx381hx151qckvvh8hbznfsfav8w0dfbd1bransf";
};
nativeBuildInputs = [ wrapGAppsHook ];
dontWrapGApps = true;
libPath = stdenv.lib.makeLibraryPath [
libcxx systemd libpulseaudio
stdenv.cc.cc alsaLib atk at-spi2-atk 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
];
installPhase = ''
mkdir -p $out/{bin,opt/discord,share/pixmaps}
mv * $out/opt/discord
chmod +x $out/opt/discord/Discord
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
$out/opt/discord/Discord
wrapProgram $out/opt/discord/Discord \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--prefix LD_LIBRARY_PATH : ${libPath}
ln -s $out/opt/discord/Discord $out/bin/
ln -s $out/opt/discord/discord.png $out/share/pixmaps
ln -s "${desktopItem}/share/applications" $out/share/
'';
desktopItem = makeDesktopItem {
name = pname;
exec = "Discord";
icon = pname;
let
inherit (pkgs) callPackage fetchurl;
in {
stable = callPackage ./base.nix {
pname = "discord";
binaryName = "Discord";
desktopName = "Discord";
genericName = meta.description;
categories = "Network;InstantMessaging;";
version = "0.0.9";
src = fetchurl {
url = "https://dl.discordapp.net/apps/linux/0.0.9/discord-0.0.9.tar.gz";
sha256 = "1i0f8id10rh2fx381hx151qckvvh8hbznfsfav8w0dfbd1bransf";
};
};
meta = with stdenv.lib; {
description = "All-in-one cross-platform voice and text chat for gamers";
homepage = https://discordapp.com/;
downloadPage = "https://github.com/crmarsh/discord-linux-bugs";
license = licenses.unfree;
maintainers = [ maintainers.ldesgoui maintainers.MP2E ];
platforms = [ "x86_64-linux" ];
ptb = callPackage ./base.nix {
pname = "discord-ptb";
binaryName = "DiscordPTB";
desktopName = "Discord PTB";
version = "0.0.15";
src = fetchurl {
url = "https://dl-ptb.discordapp.net/apps/linux/0.0.15/discord-ptb-0.0.15.tar.gz";
sha256 = "0znqb0a3yglgx7a9ypkb81jcm8kqgc6559zi7vfqn02zh15gqv6a";
};
};
}
canary = callPackage ./base.nix {
pname = "discord-canary";
binaryName = "DiscordCanary";
desktopName = "Discord Canary";
version = "0.0.83";
src = fetchurl {
url = "https://dl-canary.discordapp.net/apps/linux/0.0.83/discord-canary-0.0.83.tar.gz";
sha256 = "100a61x71cgyfm0xk4qdlbp1v41089jy7lajksbpy4y7him6bg2s";
};
};
}.${branch}

View File

@ -24135,7 +24135,20 @@ in
togglesg-download = callPackage ../tools/misc/togglesg-download { };
discord = callPackage ../applications/networking/instant-messengers/discord { };
discord = import ../applications/networking/instant-messengers/discord {
branch = "stable";
inherit pkgs;
};
discord-ptb = import ../applications/networking/instant-messengers/discord {
branch = "ptb";
inherit pkgs;
};
discord-canary = import ../applications/networking/instant-messengers/discord {
branch = "canary";
inherit pkgs;
};
golden-cheetah = libsForQt56.callPackage ../applications/misc/golden-cheetah {};