biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / misc / 1password / update.sh
blob562c1af31a257a6a56280f734183bbe36d7f2163
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused nurl xq-xml
4 set -eu
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_linux() {
14 VER="$1"
15 ARCH="$2"
16 URL="https://cache.agilebits.com/dist/1P/op2/pkg/v${VER}/op_${ARCH}_v${VER}.zip"
17 nurl --hash --expr "(import <nixpkgs> { }).fetchzip { url = \"$URL\"; stripRoot = false; }"
20 fetch_darwin() {
21 VER="$1"
22 URL="https://cache.agilebits.com/dist/1P/op2/pkg/v${VER}/op_apple_universal_v${VER}.pkg"
23 nurl --hash --expr "(import <nixpkgs> { }).fetchurl { url = \"$URL\"; }"
26 replace_sha() {
27 sed -i "s|\"$1\" \"sha256-.\{44\}\"|\"$1\" \"$2\"|" "$NIX_DRV"
30 CLI_VERSION="$(curl -Ls https://app-updates.agilebits.com/product_history/CLI2 | xq -q 'h3' | head -n1)"
32 CLI_LINUX_AARCH64_SHA256=$(fetch_linux "$CLI_VERSION" "linux_arm64")
33 CLI_LINUX_I686_SHA256=$(fetch_linux "$CLI_VERSION" "linux_386")
34 CLI_LINUX_X64_SHA256=$(fetch_linux "$CLI_VERSION" "linux_amd64")
35 CLI_DARWIN_UNIVERSAL_SHA256=$(fetch_darwin "$CLI_VERSION")
37 sed -i "s/version = \".*\"/version = \"$CLI_VERSION\"/" "$NIX_DRV"
39 replace_sha "linux_arm64" "$CLI_LINUX_AARCH64_SHA256"
40 replace_sha "linux_386" "$CLI_LINUX_I686_SHA256"
41 replace_sha "linux_amd64" "$CLI_LINUX_X64_SHA256"
42 replace_sha "apple_universal" "$CLI_DARWIN_UNIVERSAL_SHA256"