linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / tools / networking / boundary / update.sh
blob437339307104dec5ced9cc1b35eba5a93a39bd0a
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://releases.hashicorp.com/boundary/${VER}/boundary_${VER}_${ARCH}.zip"
16 nix-prefetch "{ stdenv, fetchzip }:
17 stdenv.mkDerivation rec {
18 pname = \"boundary\"; version = \"${VER}\";
19 src = fetchzip { url = \"$URL\"; };
24 replace_sha() {
25 sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV"
28 # https://releases.hashicorp.com/boundary/0.1.4/boundary_0.1.4_linux_amd64.zip
29 BOUNDARY_VER=$(curl -Ls -w "%{url_effective}" -o /dev/null https://github.com/hashicorp/boundary/releases/latest | awk -F'/' '{print $NF}' | sed 's/v//')
31 BOUNDARY_LINUX_X64_SHA256=$(fetch_arch "$BOUNDARY_VER" "linux_amd64")
32 BOUNDARY_DARWIN_X64_SHA256=$(fetch_arch "$BOUNDARY_VER" "darwin_amd64")
33 BOUNDARY_LINUX_AARCH64_SHA256=$(fetch_arch "$BOUNDARY_VER" "linux_arm64")
35 sed -i "s/version = \".*\"/version = \"$BOUNDARY_VER\"/" "$NIX_DRV"
37 replace_sha "x86_64-linux" "$BOUNDARY_LINUX_X64_SHA256"
38 replace_sha "x86_64-darwin" "$BOUNDARY_DARWIN_X64_SHA256"
39 replace_sha "aarch64-linux" "$BOUNDARY_LINUX_AARCH64_SHA256"