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