discord: Fix autoupdate script

It didn't properly detect which of the versions it updated.

(cherry picked from commit 83af8ef00e33affadd1df45af48866f24625566c)
This commit is contained in:
Moritz Hedtke 2021-06-29 16:09:05 +02:00 committed by github-actions[bot]
parent b106a26a4d
commit 77d82ccb4f
2 changed files with 10 additions and 37 deletions

View File

@ -5,6 +5,7 @@
, libX11, libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext , libX11, libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext
, libXfixes, libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence , libXfixes, libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence
, mesa, nspr, nss, pango, systemd, libappindicator-gtk3, libdbusmenu , mesa, nspr, nss, pango, systemd, libappindicator-gtk3, libdbusmenu
, writeScript, common-updater-scripts
}: }:
let let
@ -69,7 +70,15 @@ in stdenv.mkDerivation rec {
mimeType = "x-scheme-handler/discord"; 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}
${common-updater-scripts}/bin/update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix
'';
meta = with lib; { meta = with lib; {
description = "All-in-one cross-platform voice and text chat for gamers"; description = "All-in-one cross-platform voice and text chat for gamers";

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}"