forked from
lass.pds.lassul.us/superconfig
This repository has no description
1.7 kB
43 lines
1#!/usr/bin/env bash
2set -euo pipefail
3
4# Upstream publishes a different set of platform wheels per release (no macOS
5# wheel since 0.3.45), so each platform in wheels.json tracks the newest PyPI
6# release that still ships its wheel tag. Hashes come from PyPI's sha256
7# digests; a final build verifies the result.
8# Run by update-pkgs from the flake root ($0 is a read-only store copy).
9attr=vosk
10json=pkgs/vosk/wheels.json
11system=$(nix eval --raw --impure --expr 'builtins.currentSystem')
12
13pypi=$(curl -fsSL https://pypi.org/pypi/vosk/json)
14
15new=$(jq -c . "$json")
16for platform in $(jq -r 'keys[]' "$json"); do
17 tag=$(jq -r --arg p "$platform" '.[$p].tag' "$json")
18 # Newest non-yanked release providing vosk-<v>-py3-none-<tag>.whl.
19 match=$(jq -r --arg tag "$tag" '
20 .releases | to_entries[]
21 | .key as $v
22 | .value[]
23 | select(.yanked | not)
24 | select(.filename == "vosk-\($v)-py3-none-\($tag).whl")
25 | "\($v) \(.digests.sha256)"' <<<"$pypi" | sort -V -k1,1 | tail -n1)
26 if [ -z "$match" ]; then
27 echo "$attr: no wheel for $platform ($tag) on PyPI" >&2
28 exit 1
29 fi
30 version=${match%% *}
31 hash=$(nix hash convert --hash-algo sha256 --to sri "${match##* }")
32 new=$(jq -c --arg p "$platform" --arg v "$version" --arg h "$hash" \
33 '.[$p].version = $v | .[$p].hash = $h' <<<"$new")
34done
35
36if [ "$(jq -S . <<<"$new")" = "$(jq -S . "$json")" ]; then
37 echo "$attr: already up to date ($(jq -r '[.[].version] | unique | join(", ")' "$json"))"
38 exit 0
39fi
40
41jq . <<<"$new" >"$json"
42echo "$attr: updated to $(jq -r 'to_entries | map("\(.key)=\(.value.version)") | join(", ")' "$json")"
43nix build --no-link ".#packages.$system.$attr"