anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / applications / networking / instant-messengers / element / update.sh
blob2a4ec5fcdec2459be8bc04e51311606701b6d213
1 #!/usr/bin/env nix-shell
2 #!nix-shell -I nixpkgs=../../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
4 if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
5 echo "Regenerates packaging data for the element packages."
6 echo "Usage: $0 [git release tag]"
7 exit 1
8 fi
10 version="$1"
12 set -euo pipefail
14 if [ -z "$version" ]; then
15 version="$(wget -q -O- "https://api.github.com/repos/element-hq/element-desktop/releases?per_page=1" | jq -r '.[0].tag_name')"
18 # strip leading "v"
19 version="${version#v}"
21 # Element Web
22 web_src="https://raw.githubusercontent.com/element-hq/element-web/v$version"
23 web_src_hash=$(nix-prefetch-github element-hq element-web --rev v${version} | jq -r .hash)
25 web_tmpdir=$(mktemp -d)
26 trap 'rm -rf "$web_tmpdir"' EXIT
28 pushd $web_tmpdir
29 wget -q "$web_src/yarn.lock"
30 web_yarn_hash=$(prefetch-yarn-deps yarn.lock)
31 popd
33 # Element Desktop
34 desktop_src="https://raw.githubusercontent.com/element-hq/element-desktop/v$version"
35 desktop_src_hash=$(nix-prefetch-github element-hq element-desktop --rev v${version} | jq -r .hash)
37 desktop_tmpdir=$(mktemp -d)
38 trap 'rm -rf "$desktop_tmpdir"' EXIT
40 pushd $desktop_tmpdir
41 wget -q "$desktop_src/yarn.lock"
42 desktop_yarn_hash=$(prefetch-yarn-deps yarn.lock)
43 popd
45 cat > pin.nix << EOF
47 "version" = "$version";
48 "hashes" = {
49 "desktopSrcHash" = "$desktop_src_hash";
50 "desktopYarnHash" = "$desktop_yarn_hash";
51 "webSrcHash" = "$web_src_hash";
52 "webYarnHash" = "$web_yarn_hash";
55 EOF