2019-06-19 05:39:15 +00:00
|
|
|
#!/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 }:
|
2019-10-12 03:48:57 +00:00
|
|
|
# Generated by /maintainers/scripts/update-discord
|
2019-06-19 05:39:15 +00:00
|
|
|
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}
|
2019-10-12 03:48:57 +00:00
|
|
|
echo " ${branch:-stable} = callPackage ./base.nix rec {"
|
2019-06-19 05:39:15 +00:00
|
|
|
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 {"
|
2019-10-12 03:48:57 +00:00
|
|
|
echo " url = \"${url//${version}/\$\{version\}}\";"
|
2019-06-19 05:39:15 +00:00
|
|
|
echo " sha256 = \"$(nix-prefetch-url "$url")\";"
|
|
|
|
echo " };"
|
|
|
|
echo " };"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "}.\${branch}"
|