This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / pkgs / omnigent / update.sh
2.0 kB 58 lines
1#!/usr/bin/env bash 2set -euo pipefail 3 4# omnigent, omnigent-client and omnigent-ui-sdk are released in lockstep and 5# all three are fetched as py3 wheels in package.nix; nix-update only bumps 6# the top-level src, so bump all of them here. 7attr=omnigent 8 9# Run by update-pkgs from the flake root ($0 is a read-only store copy). 10pkg=pkgs/omnigent/package.nix 11system=$(nix eval --raw --impure --expr 'builtins.currentSystem') 12 13new_version=$(curl -fsSL https://pypi.org/pypi/omnigent/json | jq -r .info.version) 14old_version=$(sed -n 's|^ version = "\([^"]*\)";|\1|p' "$pkg") 15if [ "$old_version" = "$new_version" ]; then 16 echo "$attr: already up to date ($new_version)" 17 exit 0 18fi 19 20# Hash of the py3-none-any wheel as published on PyPI, in SRI form. 21wheel_hash() { 22 local project=$1 hex 23 hex=$(curl -fsSL "https://pypi.org/pypi/$project/$new_version/json" | 24 jq -r '.urls[] | select(.packagetype == "bdist_wheel" and (.filename | endswith("-py3-none-any.whl"))) | .digests.sha256') 25 if [ -z "$hex" ]; then 26 echo "$attr: no py3-none-any wheel for $project $new_version" >&2 27 exit 1 28 fi 29 nix hash convert --hash-algo sha256 --to sri "$hex" 30} 31 32# Replace the `hash = ...` that follows `pname = "<pname>"` (blanking first so 33# nothing ever builds against a stale cached FOD). 34set_hash() { 35 local pname=$1 hash=$2 36 sed -i "/pname = \"$pname\";/,/hash = /s|^\(\s*\)hash = \"[^\"]*\"|\1hash = \"$hash\"|" "$pkg" 37} 38 39client_hash=$(wheel_hash omnigent-client) 40ui_sdk_hash=$(wheel_hash omnigent-ui-sdk) 41app_hash=$(wheel_hash omnigent) 42 43sed -i \ 44 -e "s|^\(\s*\)version = \"$old_version\";|\1version = \"$new_version\";|" \ 45 -e "s|^\(\s*\)hash = \".*\"|\1hash = \"\"|" \ 46 "$pkg" 47 48set_hash omnigent_client "$client_hash" 49set_hash omnigent_ui_sdk "$ui_sdk_hash" 50set_hash omnigent "$app_hash" 51 52if grep -q 'hash = ""' "$pkg"; then 53 echo "$attr: failed to fill in every hash" >&2 54 exit 1 55fi 56 57echo "$attr: updated $old_version → $new_version" 58nix build --no-link ".#packages.$system.$attr"