base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12 (#356361)
[NixPkgs.git] / pkgs / tools / networking / zrok / update.sh
blob71a09919a8507a28e8cbef621351eb73c192979b
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused gawk nix-prefetch
4 set -euo pipefail
6 ROOT="$(dirname "$(readlink -f "$0")")"
7 NIX_DRV="$ROOT/default.nix"
8 if [ ! -f "$NIX_DRV" ]; then
9 echo "ERROR: cannot find default.nix in $ROOT"
10 exit 1
13 fetch_arch() {
14 VER="$1"; ARCH="$2"
15 URL="https://github.com/openziti/zrok/releases/download/v${VER}/zrok_${VER}_${ARCH}.tar.gz"
16 nix-prefetch "{ stdenv, fetchzip }:
17 stdenv.mkDerivation rec {
18 pname = \"zrok\"; version = \"${VER}\";
19 src = fetchzip { url = \"$URL\"; stripRoot = false; };
24 replace_sha() {
25 sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV"
28 ZROK_VER=$(curl -Ls -w "%{url_effective}" -o /dev/null https://github.com/openziti/zrok/releases/latest | awk -F'/' '{print $NF}' | sed 's/v//')
30 ZROK_LINUX_X64_SHA256=$(fetch_arch "$ZROK_VER" "linux_amd64")
31 ZROK_LINUX_AARCH64_SHA256=$(fetch_arch "$ZROK_VER" "linux_arm64")
32 ZROK_LINUX_ARMV7L_SHA256=$(fetch_arch "$ZROK_VER" "linux_armv7")
34 sed -i "s/version = \".*\"/version = \"$ZROK_VER\"/" "$NIX_DRV"
36 replace_sha "x86_64-linux" "$ZROK_LINUX_X64_SHA256"
37 replace_sha "aarch64-linux" "$ZROK_LINUX_AARCH64_SHA256"
38 replace_sha "armv7l-linux" "$ZROK_LINUX_ARMV7L_SHA256"