alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
pkgs.kokoro: add updateScript
author
lassulus
date
1 week ago
(Oct 13, 2026, 2:14 AM CEST)
commit
aee0b5cd
aee0b5cd0470371917e1f953e2313c39de4e476b
parent
3306bf9e
3306bf9e5842c14f239b0e8effa2b9dfccbd6899
+97
2 changed files
Expand all
Collapse all
Unified
Split
pkgs
kokoro
package.nix
update.sh
+4
pkgs/kokoro/package.nix
View file
Reviewed
···
20
20
patches = (old.patches or [ ]) ++ [
21
21
./stdout-support.patch
22
22
];
23
23
+
passthru = (old.passthru or { }) // {
24
24
+
# Bumps kokoro (main branch) and the spacy model wheel together.
25
25
+
updateScript = ./update.sh;
26
26
+
};
23
27
});
24
28
# Spacy model - downloaded and packaged as a python package
25
29
spacy-en-core-web-sm = final.buildPythonPackage rec {
+93
pkgs/kokoro/update.sh
View file
Reviewed
···
1
1
+
#!/usr/bin/env bash
2
2
+
set -euo pipefail
3
3
+
4
4
+
# Bumps two sources together: hexgrad/kokoro (main branch, 0-unstable-DATE)
5
5
+
# and the en_core_web_sm wheel misaki needs. The spacy model only loads with a
6
6
+
# matching spacy major.minor, so it follows the newest model release for the
7
7
+
# spacy version in our nixpkgs.
8
8
+
attr=kokoro
9
9
+
owner=hexgrad
10
10
+
repo=kokoro
11
11
+
branch=main
12
12
+
13
13
+
# Run by update-pkgs from the flake root ($0 is a read-only store copy).
14
14
+
pkg=pkgs/kokoro/package.nix
15
15
+
system=$(nix eval --raw --impure --expr 'builtins.currentSystem')
16
16
+
build_attr=".#packages.$system.$attr"
17
17
+
18
18
+
# Line number of the n-th line matching an ERE.
19
19
+
line_of() {
20
20
+
grep -nE "$1" "$pkg" | awk -F: -v n="${2:-1}" 'NR == n { print $1 }'
21
21
+
}
22
22
+
# Replace the quoted value on line $1.
23
23
+
set_value() {
24
24
+
local tmp
25
25
+
tmp=$(mktemp)
26
26
+
awk -v l="$1" -v v="$2" 'NR == l { sub(/"[^"]*"/, "\"" v "\"") } { print }' "$pkg" >"$tmp"
27
27
+
cat "$tmp" >"$pkg"
28
28
+
rm -f "$tmp"
29
29
+
}
30
30
+
value_at() {
31
31
+
awk -v l="$1" 'NR == l { match($0, /"[^"]*"/); print substr($0, RSTART + 1, RLENGTH - 2) }' "$pkg"
32
32
+
}
33
33
+
34
34
+
# Field locations: kokoro block first, spacy model block second.
35
35
+
kokoro_version_line=$(line_of '^[[:space:]]*version = "0-unstable-')
36
36
+
kokoro_rev_line=$(line_of '^[[:space:]]*rev = "')
37
37
+
kokoro_hash_line=$(line_of '^[[:space:]]*hash = "' 1)
38
38
+
model_version_line=$(line_of '^[[:space:]]*version = "[0-9]+\.[0-9]+\.[0-9]+"')
39
39
+
model_hash_line=$(line_of '^[[:space:]]*hash = "' 2)
40
40
+
41
41
+
old_rev=$(value_at "$kokoro_rev_line")
42
42
+
old_model=$(value_at "$model_version_line")
43
43
+
44
44
+
new_rev=$(curl -fsSL "https://api.github.com/repos/$owner/$repo/commits/$branch" | jq -r .sha)
45
45
+
46
46
+
spacy_version=$(nix eval --raw "$build_attr.pythonModule.pkgs.spacy.version")
47
47
+
spacy_mm=$(echo "$spacy_version" | cut -d. -f1-2)
48
48
+
new_model=$(curl -fsSL "https://api.github.com/repos/explosion/spacy-models/releases?per_page=100" |
49
49
+
jq -r --arg p "en_core_web_sm-$spacy_mm." '
50
50
+
[.[] | select(.prerelease | not) | .tag_name | select(startswith($p))
51
51
+
| ltrimstr("en_core_web_sm-")]
52
52
+
| sort_by(split(".") | map(tonumber)) | last // empty')
53
53
+
if [ -z "$new_model" ]; then
54
54
+
echo "$attr: no en_core_web_sm release for spacy $spacy_mm, keeping $old_model" >&2
55
55
+
new_model=$old_model
56
56
+
fi
57
57
+
58
58
+
if [ "$old_rev" = "$new_rev" ] && [ "$old_model" = "$new_model" ]; then
59
59
+
echo "$attr: already up to date ($new_rev, en_core_web_sm $new_model)"
60
60
+
exit 0
61
61
+
fi
62
62
+
63
63
+
# Blank the hashes of whatever changed: with the old ones in place nix reuses
64
64
+
# the cached FODs and the build "succeeds" on stale sources.
65
65
+
if [ "$old_rev" != "$new_rev" ]; then
66
66
+
new_date=$(curl -fsSL "https://api.github.com/repos/$owner/$repo/commits/$new_rev" | jq -r .commit.committer.date | cut -d T -f1)
67
67
+
set_value "$kokoro_rev_line" "$new_rev"
68
68
+
set_value "$kokoro_version_line" "0-unstable-$new_date"
69
69
+
set_value "$kokoro_hash_line" ""
70
70
+
fi
71
71
+
if [ "$old_model" != "$new_model" ]; then
72
72
+
set_value "$model_version_line" "$new_model"
73
73
+
set_value "$model_hash_line" ""
74
74
+
fi
75
75
+
76
76
+
# Probe builds are *expected* to fail (hash mismatch); `|| true` keeps
77
77
+
# errexit from aborting. One FOD fails per build; the two fetches are
78
78
+
# independent, so match the reported derivation name to pick the field.
79
79
+
for _ in 1 2; do
80
80
+
out=$({ nix build --no-link "$build_attr" 2>&1 || true; } | tee /dev/stderr)
81
81
+
got=$(echo "$out" | awk '/got:/ && !seen { print $2; seen = 1 }')
82
82
+
[ -n "$got" ] || break
83
83
+
if echo "$out" | grep -q 'hash mismatch in fixed-output derivation.*en_core_web_sm'; then
84
84
+
set_value "$model_hash_line" "$got"
85
85
+
echo "$attr: en_core_web_sm hash → $got"
86
86
+
else
87
87
+
set_value "$kokoro_hash_line" "$got"
88
88
+
echo "$attr: src hash → $got"
89
89
+
fi
90
90
+
done
91
91
+
92
92
+
echo "$attr: updated to $new_rev, en_core_web_sm $new_model"
93
93
+
nix build --no-link "$build_attr"