mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(nix): refresh stale tui npmDepsHash + fix cache-blind detection (#20144)
The fix-lockfiles script used 'nix build .#tui.npmDeps' to detect stale hashes. This always succeeds when the OLD derivation is cached in Cachix or cache.nixos.org — even when the source package-lock.json has changed. Fix: use prefetch-npm-deps to compute the hash directly from the lockfile and compare against what's in the nix file. Falls back to nix build only if prefetch-npm-deps fails.
This commit is contained in:
parent
601e5f1d57
commit
13a7cbcd64
2 changed files with 32 additions and 25 deletions
55
nix/lib.nix
55
nix/lib.nix
|
|
@ -163,35 +163,42 @@
|
||||||
for entry in "''${ENTRIES[@]}"; do
|
for entry in "''${ENTRIES[@]}"; do
|
||||||
IFS=":" read -r ATTR FOLDER NIX_FILE <<< "$entry"
|
IFS=":" read -r ATTR FOLDER NIX_FILE <<< "$entry"
|
||||||
echo "==> .#$ATTR ($FOLDER -> $NIX_FILE)"
|
echo "==> .#$ATTR ($FOLDER -> $NIX_FILE)"
|
||||||
OUTPUT=$(nix build ".#$ATTR.npmDeps" --no-link --print-build-logs 2>&1)
|
|
||||||
STATUS=$?
|
# Compute the actual hash from the lockfile directly using
|
||||||
if [ "$STATUS" -eq 0 ]; then
|
# prefetch-npm-deps. This avoids false "ok" from nix build when
|
||||||
|
# an old derivation is cached in a substituter (cachix/cache.nixos.org).
|
||||||
|
LOCK_FILE="$FOLDER/package-lock.json"
|
||||||
|
NEW_HASH=$(${pkgs.lib.getExe pkgs.prefetch-npm-deps} "$LOCK_FILE" 2>/dev/null)
|
||||||
|
if [ -z "$NEW_HASH" ]; then
|
||||||
|
echo " prefetch-npm-deps failed, falling back to nix build" >&2
|
||||||
|
OUTPUT=$(nix build ".#$ATTR.npmDeps" --no-link --print-build-logs 2>&1)
|
||||||
|
STATUS=$?
|
||||||
|
if [ "$STATUS" -eq 0 ]; then
|
||||||
|
echo " ok (via nix build)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
NEW_HASH=$(echo "$OUTPUT" | awk '/got:/ {print $2; exit}')
|
||||||
|
if [ -z "$NEW_HASH" ]; then
|
||||||
|
if echo "$OUTPUT" | grep -qE "throttled|HTTP error 418|substituter .* is disabled|some outputs of .* are not valid"; then
|
||||||
|
echo " skipped (transient cache failure — see primary nix build for real status)" >&2
|
||||||
|
echo "$OUTPUT" | tail -8 >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo " build failed with no hash mismatch:" >&2
|
||||||
|
echo "$OUTPUT" | tail -40 >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
OLD_HASH=$(grep -oE 'hash = "sha256-[^"]+"' "$NIX_FILE" | head -1 \
|
||||||
|
| sed -E 's/hash = "(.*)"/\1/')
|
||||||
|
|
||||||
|
if [ "$NEW_HASH" = "$OLD_HASH" ]; then
|
||||||
echo " ok"
|
echo " ok"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEW_HASH=$(echo "$OUTPUT" | awk '/got:/ {print $2; exit}')
|
|
||||||
if [ -z "$NEW_HASH" ]; then
|
|
||||||
# Magic-Nix-Cache occasionally returns HTTP 418 / cache-throttled
|
|
||||||
# mid-run; nix then prints "outputs … not valid, so checking is
|
|
||||||
# not possible" without a `got:` line. That's an infrastructure
|
|
||||||
# blip, not a stale lockfile — warn + skip rather than failing
|
|
||||||
# the lint. A real hash mismatch would still surface in the
|
|
||||||
# primary `.#$ATTR` build, which is a separate CI job.
|
|
||||||
if echo "$OUTPUT" | grep -qE "throttled|HTTP error 418|substituter .* is disabled|some outputs of .* are not valid"; then
|
|
||||||
echo " skipped (transient cache failure — see primary nix build for real status)" >&2
|
|
||||||
echo "$OUTPUT" | tail -8 >&2
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo " build failed with no hash mismatch:" >&2
|
|
||||||
echo "$OUTPUT" | tail -40 >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
HASH_LINE=$(grep -n 'hash = "sha256-' "$NIX_FILE" | head -1 | cut -d: -f1)
|
HASH_LINE=$(grep -n 'hash = "sha256-' "$NIX_FILE" | head -1 | cut -d: -f1)
|
||||||
OLD_HASH=$(grep -oE 'hash = "sha256-[^"]+"' "$NIX_FILE" | head -1 \
|
|
||||||
| sed -E 's/hash = "(.*)"/\1/')
|
|
||||||
LOCK_FILE="$FOLDER/package-lock.json"
|
|
||||||
echo " stale: $NIX_FILE:$HASH_LINE $OLD_HASH -> $NEW_HASH"
|
echo " stale: $NIX_FILE:$HASH_LINE $OLD_HASH -> $NEW_HASH"
|
||||||
STALE=1
|
STALE=1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ let
|
||||||
src = ../ui-tui;
|
src = ../ui-tui;
|
||||||
npmDeps = pkgs.fetchNpmDeps {
|
npmDeps = pkgs.fetchNpmDeps {
|
||||||
inherit src;
|
inherit src;
|
||||||
hash = "sha256-a/HGI9OgVcTnZrMXA7xFMGnFoVxyHe95fulVz+WNYB0=";
|
hash = "sha256-MLcLhjTF6dgdvNBtJWzo8Nh19eNh/ZitD2b07nm61Tc=";
|
||||||
};
|
};
|
||||||
|
|
||||||
npm = hermesNpmLib.mkNpmPassthru { folder = "ui-tui"; attr = "tui"; pname = "hermes-tui"; };
|
npm = hermesNpmLib.mkNpmPassthru { folder = "ui-tui"; attr = "tui"; pname = "hermes-tui"; };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue