git.iko.soy/typeable/nixpkgs
on master help sign in
discord: fix updater script (#128633)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

commit8e170dc44a9d782c6991c7f9386187be3d5ffbbc authorMoritz Hedtke <13287984+mohe2015@users.noreply.github.com> dateThu 15 Jul 2021, 22:14 (5 years ago) parentdadf56e
3 files changed+12−39
pkgs/applications/networking/instant-messengers/discord/base.nix+10−1 pkgs/applications/networking/instant-messengers/discord/default.nix+2−2 pkgs/applications/networking/instant-messengers/discord/update-discord.sh−36
pkgs/applications/networking/instant-messengers/discord/base.nix+10−1
@@ -5,6 +5,7 @@
55, libX11, libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext
66, libXfixes, libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence
77, mesa, nspr, nss, pango, systemd, libappindicator-gtk3, libdbusmenu
8+, writeScript, common-updater-scripts
89}:
910
1011let
@@ -71,7 +72,15 @@ in stdenv.mkDerivation rec {
7172 mimeType = "x-scheme-handler/discord";
7273 };
7374
74− passthru.updateScript = ./update-discord.sh;
75+ passthru.updateScript = writeScript "discord-update-script" ''
76+ #!/usr/bin/env nix-shell
77+ #!nix-shell -i bash -p curl gnugrep common-updater-scripts
78+ set -eou pipefail;
79+ url=$(curl -sI "https://discordapp.com/api/download/${builtins.replaceStrings ["discord-" "discord"] ["" "stable"] pname}?platform=linux&format=tar.gz" | grep -oP 'location: \K\S+')
80+ version=''${url##https://dl*.discordapp.net/apps/linux/}
81+ version=''${version%%/*.tar.gz}
82+ update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix
83+ '';
7584
7685 meta = with lib; {
7786 description = "All-in-one cross-platform voice and text chat for gamers";
pkgs/applications/networking/instant-messengers/discord/default.nix+2−2
@@ -27,10 +27,10 @@ in {
2727 pname = "discord-canary";
2828 binaryName = "DiscordCanary";
2929 desktopName = "Discord Canary";
30− version = "0.0.125";
30+ version = "0.0.126";
3131 src = fetchurl {
3232 url = "https://dl-canary.discordapp.net/apps/linux/${version}/discord-canary-${version}.tar.gz";
33− sha256 = "0ly5a6l7rvl54mc39xma14jrcrf11q3ndnkkr16by5hy3palmz9g";
33+ sha256 = "EraTDRKd6t0c9U68tSRdGkeB1hfqNS4KUewEXwkL8io=";
3434 };
3535 };
3636}.${branch}
pkgs/applications/networking/instant-messengers/discord/update-discord.shdeleted−36
@@ -1,36 +0,0 @@
1−#!/usr/bin/env bash
2−# script to generate ./default.nix
3−
4−set -e
5−exec >"${BASH_SOURCE%/*}/default.nix"
6−
7−cat <<EOF
8−{ branch ? "stable", pkgs }:
9−# Generated by ./update-discord.sh
10−let
11− inherit (pkgs) callPackage fetchurl;
12−in {
13−EOF
14−
15−for branch in "" ptb canary; do
16− url=$(curl -sI "https://discordapp.com/api/download${branch:+/}${branch}?platform=linux&format=tar.gz" | grep -oP 'location: \K\S+')
17− version=${url##https://dl*.discordapp.net/apps/linux/}
18− version=${version%%/*.tar.gz}
19− echo " ${branch:-stable} = callPackage ./base.nix rec {"
20− echo " pname = \"discord${branch:+-}${branch}\";"
21− case $branch in
22− "") suffix="" ;;
23− ptb) suffix="PTB" ;;
24− canary) suffix="Canary" ;;
25− esac
26− echo " binaryName = \"Discord${suffix}\";"
27− echo " desktopName = \"Discord${suffix:+ }${suffix}\";"
28− echo " version = \"${version}\";"
29− echo " src = fetchurl {"
30− echo " url = \"${url//${version}/\$\{version\}}\";"
31− echo " sha256 = \"$(nix-prefetch-url "$url")\";"
32− echo " };"
33− echo " };"
34−done
35−
36−echo "}.\${branch}"