fix hash update script, and update hash

This commit is contained in:
José Albornoz
2026-03-25 22:52:43 +07:00
committed by Mohamed Boudra
parent 233b309fd9
commit 6bad956c8f
2 changed files with 17 additions and 6 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ buildNpmPackage rec {
# To update: run `nix build` with lib.fakeHash, copy the `got:` hash.
# CI auto-updates this when package-lock.json changes (see .github/workflows/).
npmDepsHash = "sha256-/jkIg4ZVLp+EuMij4YpmtbwLihUtKi8U/jLh981M4CI=";
npmDepsHash = "sha256-qRknrMt2VBCCRGGedyTrPEBs3u+Z8lmDZuuvX7mE2Cg=";
# Prevent onnxruntime-node's install script from running during automatic
# npm rebuild (it tries to download from api.nuget.org, which fails in the sandbox).
+16 -5
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Fix workspace-local lockfile entries and update the Nix dependency hash.
# Requires: node, npm, nix (with prefetch-npm-deps from nixpkgs)
# Requires: node, npm, nix
#
# Usage:
# ./scripts/update-nix.sh # fix lockfile + update hash
@@ -24,11 +24,22 @@ node "$SCRIPT_DIR/fix-lockfile.mjs" "$LOCK_FILE"
# 2. Prefetch deps and compute hash
echo "Prefetching npm dependencies..."
TMPDIR_DEPS="$(mktemp -d)"
trap "rm -rf $TMPDIR_DEPS" EXIT
prefetch-npm-deps "$LOCK_FILE" "$TMPDIR_DEPS/deps" 2>/dev/null
NEW_HASH="$(nix hash path "$TMPDIR_DEPS/deps")"
# Resolve prefetch-npm-deps from the same nixpkgs pinned in flake.lock
NIXPKGS_URL="$(node -p "
const l = JSON.parse(require('fs').readFileSync('$ROOT_DIR/flake.lock', 'utf8'));
const n = l.nodes.nixpkgs.locked;
'github:' + n.owner + '/' + n.repo + '/' + n.rev;
")"
STDERR_LOG="$(mktemp)"
trap "rm -f '$STDERR_LOG'" EXIT
if ! NEW_HASH="$(nix shell "${NIXPKGS_URL}#prefetch-npm-deps" -c prefetch-npm-deps "$LOCK_FILE" 2>"$STDERR_LOG")"; then
echo "ERROR: prefetch-npm-deps failed:" >&2
tail -20 "$STDERR_LOG" >&2
exit 1
fi
echo "Computed hash: $NEW_HASH"
# 3. Read current hash