1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p nix curl libxml2 jq
6 nixpkgs
="$(git rev-parse --show-toplevel || (printf 'Could not find root of nixpkgs repo\nAre we running from within the nixpkgs git repo?\n' >&2; exit 1))"
8 attr
="${UPDATE_NIX_ATTR_PATH:-touchosc}"
9 version
="$(curl -sSL https://hexler.net/touchosc/appcast/linux | xmllint --xpath '/rss/channel/item/enclosure/@*[local-name()="version
"]' - | cut -d= -f2- | tr -d '"' | head -n1)"
12 nix --extra-experimental-features nix-command store prefetch-file --json "$url" | jq -r .hash
16 if [ "$#" -ge 2 ]; then
17 systemargs=(--argstr system "$2")
22 nix --extra-experimental-features nix-command eval --json --impure "${systemargs[@]}" -f "$nixpkgs" "$1" | jq -r .
26 path="$(nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1.meta.position" | jq -r . | cut -d: -f1)"
27 outpath="$(nix --extra-experimental-features nix-command eval --json --impure --expr "builtins.fetchGit \"$nixpkgs\"")"
29 if [ -n "$outpath" ]; then
30 path="${path/$(echo "$outpath" | jq -r .)/$nixpkgs}"
36 oldversion="${UPDATE_NIX_OLD_VERSION:-$(nixeval "$attr".version)}"
38 pkgpath="$(findpath "$attr")"
40 if [ "$version" = "$oldversion" ]; then
41 echo 'update.sh
: New version same as old version
, nothing to
do.
'
45 sed -i -e "/version\s*=/ s|\"$oldversion\"|\"$version\"|" "$pkgpath"
47 for system in aarch64-linux armv7l-linux x86_64-linux; do
48 url="$(nixeval "$attr".src.url "$system")"
50 curhash="$(nixeval "$attr".src.outputHash "$system")"
51 newhash="$(narhash "$url")"
53 sed -i -e "s|\"$curhash\"|\"$newhash\"|" "$pkgpath"