Guest User

Untitled

a guest
Apr 18th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 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}"
  37.  
Advertisement
Add Comment
Please, Sign In to add comment