discord: fix updater script (#128633)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
Moritz Hedtke 2021-07-15 22:14:41 +02:00 committed by GitHub
parent dadf56e3a6
commit 8e170dc44a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 39 deletions

View File

@ -5,6 +5,7 @@
, libX11, libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext
, libXfixes, libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence
, mesa, nspr, nss, pango, systemd, libappindicator-gtk3, libdbusmenu
, writeScript, common-updater-scripts
}:
let
@ -71,7 +72,15 @@ in stdenv.mkDerivation rec {
mimeType = "x-scheme-handler/discord";
};
passthru.updateScript = ./update-discord.sh;
passthru.updateScript = writeScript "discord-update-script" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep common-updater-scripts
set -eou pipefail;
url=$(curl -sI "https://discordapp.com/api/download/${builtins.replaceStrings ["discord-" "discord"] ["" "stable"] pname}?platform=linux&format=tar.gz" | grep -oP 'location: \K\S+')
version=''${url##https://dl*.discordapp.net/apps/linux/}
version=''${version%%/*.tar.gz}
update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix
'';
meta = with lib; {
description = "All-in-one cross-platform voice and text chat for gamers";

View File

@ -27,10 +27,10 @@ in {
pname = "discord-canary";
binaryName = "DiscordCanary";
desktopName = "Discord Canary";
version = "0.0.125";
version = "0.0.126";
src = fetchurl {
url = "https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
sha256 = "0ly5a6l7rvl54mc39xma14jrcrf11q3ndnkkr16by5hy3palmz9g";
sha256 = "EraTDRKd6t0c9U68tSRdGkeB1hfqNS4KUewEXwkL8io=";
};
};
}.${branch}

View File

@ -1,36 +0,0 @@
#!/usr/bin/env bash
# script to generate ./default.nix
set -e
exec >"${BASH_SOURCE%/*}/default.nix"
cat <<EOF
{ branch ? "stable", pkgs }:
# Generated by ./update-discord.sh
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 rec {"
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//${version}/\$\{version\}}\";"
echo " sha256 = \"$(nix-prefetch-url "$url")\";"
echo " };"
echo " };"
done
echo "}.\${branch}"