1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused gawk nix-prefetch
6 ROOT
="$(dirname "$
(readlink
-f "$0")")"
7 NIX_DRV
="$ROOT/package.nix"
8 if [ ! -f "$NIX_DRV" ]; then
9 echo "ERROR: cannot find package.nix in $ROOT"
13 function calc_hash
() {
16 url
="https://releases.hashicorp.com/boundary/${version}/boundary_${version}_${arch}.zip"
17 zip_hash
=$
(nix-prefetch-url
--unpack $url)
18 nix
hash to-sri
--type sha256
"$zip_hash"
22 sed -i "s#$1 = \"sha256-.\{44\}\"#$1 = \"$2\"#" "$NIX_DRV"
25 # https://releases.hashicorp.com/boundary/0.1.4/boundary_0.1.4_linux_amd64.zip
26 BOUNDARY_VER
=$
(curl
-Ls -w "%{url_effective}" -o /dev
/null https
://github.com
/hashicorp
/boundary
/releases
/latest |
awk -F'/' '{print $NF}' |
sed 's/v//')
28 BOUNDARY_LINUX_X64_SHA256
=$
(calc_hash
"$BOUNDARY_VER" "linux_amd64")
29 BOUNDARY_DARWIN_X64_SHA256
=$
(calc_hash
"$BOUNDARY_VER" "darwin_amd64")
30 BOUNDARY_LINUX_AARCH64_SHA256
=$
(calc_hash
"$BOUNDARY_VER" "linux_arm64")
31 BOUNDARY_DARWIN_AARCH64_SHA256
=$
(calc_hash
"$BOUNDARY_VER" "darwin_arm64")
33 sed -i "s/version = \".*\"/version = \"$BOUNDARY_VER\"/" "$NIX_DRV"
35 replace_sha
"x86_64-linux" "$BOUNDARY_LINUX_X64_SHA256"
36 replace_sha
"x86_64-darwin" "$BOUNDARY_DARWIN_X64_SHA256"
37 replace_sha
"aarch64-linux" "$BOUNDARY_LINUX_AARCH64_SHA256"
38 replace_sha
"aarch64-darwin" "$BOUNDARY_DARWIN_AARCH64_SHA256"