This repository has no description
0

Configure Feed

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

superconfig / 5pkgs / tincr / update.sh
1.7 kB 57 lines
1#!/usr/bin/env bash 2set -euo pipefail 3 4# Tracks our fork's fix branch (Mic92/tincr#101); switch back to 5# Mic92/main once merged. 6owner=Lassulus 7repo=tincr 8branch=fix/edge-walk-address 9attr=tincr 10 11pkg="$(dirname "$(realpath "$0")")/package.nix" 12 13cd "$(dirname "$(realpath "$0")")" 14while [ ! -e flake.nix ] && [ "$PWD" != / ]; do cd ..; done 15system=$(nix eval --raw --impure --expr 'builtins.currentSystem') 16 17new_rev=$(curl -fsSL "https://api.github.com/repos/$owner/$repo/commits/$branch" | jq -r .sha) 18old_rev=$(grep -oP '^\s*rev = "\K[^"]+' "$pkg") 19if [ "$old_rev" = "$new_rev" ]; then 20 echo "$attr: already up to date ($new_rev)" 21 exit 0 22fi 23 24new_date=$(curl -fsSL "https://api.github.com/repos/$owner/$repo/commits/$new_rev" | jq -r .commit.author.date | cut -d T -f1) 25new_version="0-unstable-$new_date" 26 27# Bump rev + version, leave hashes for nix to complain about. 28sed -i \ 29 -e "s|^\(\s*\)rev = \".*\"|\1rev = \"$new_rev\"|" \ 30 -e "s|^\(\s*\)version = \".*\"|\1version = \"$new_version\"|" \ 31 "$pkg" 32 33# Each FOD reports its own hash on first miss; build twice (src, then vendor). 34extract_got() { 35 awk '/got:/{print $2; exit}' 36} 37update_hash() { 38 local field=$1 new=$2 39 sed -i "s|^\(\s*\)$field = \"[^\"]*\"|\1$field = \"$new\"|" "$pkg" 40} 41 42build_attr=".#packages.$system.$attr" 43 44if got=$(nix build --no-link "$build_attr" 2>&1 | tee /dev/stderr | extract_got) \ 45 && [ -n "$got" ]; then 46 update_hash hash "$got" 47 echo "$attr: src hash → $got" 48fi 49 50if got=$(nix build --no-link "$build_attr" 2>&1 | tee /dev/stderr | extract_got) \ 51 && [ -n "$got" ]; then 52 update_hash cargoHash "$got" 53 echo "$attr: cargoHash → $got" 54fi 55 56echo "$attr: updated to $new_rev ($new_version)" 57nix build --no-link "$build_attr"