Files
nixpkgs/pkgs/by-name/op/open-webui/update.sh
stefan 085073e86e open-webui: fix pyodide update, update pyodide to 0.29.3
The update script read the pyodide version from package.json, but the
actual version locked in package-lock.json can be different. This is
currently the case, since the derivation used an older version (0.28.2)
than the locked one (0.28.3), breaking in-browser python evaluation.

Instead, extract the pyodide version from package-lock.json, using the
jq command previously suggested in the TODO comment.

Also remove the version comparison against the existing value:
- bash string comparison is lexographic, which is incorrect for semver
- update-sourcce-version is already idempotent
- we want to always match the locked pyodide version, even if it gets
  downgraded

Run the update script twice, to update pyodide to the correct version
and to verify idempotency.
2026-05-16 10:56:08 -07:00

30 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git curl jq common-updater-scripts prefetch-npm-deps
set -eou pipefail
nixpkgs="$(git rev-parse --show-toplevel)"
path="$nixpkgs/pkgs/by-name/op/open-webui/package.nix"
version="$(curl --silent "https://api.github.com/repos/open-webui/open-webui/releases" | jq '.[0].tag_name' --raw-output)"
update-source-version open-webui "${version:1}" --file="$path"
# Fetch npm deps and pyodide
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
curl -O --output-dir $tmpdir "https://raw.githubusercontent.com/open-webui/open-webui/refs/tags/${version}/package-lock.json"
curl -O --output-dir $tmpdir "https://raw.githubusercontent.com/open-webui/open-webui/refs/tags/${version}/package.json"
pushd $tmpdir
# Prefetch the npm dependencies hash
npm_hash=$(prefetch-npm-deps package-lock.json)
sed -i 's#npmDepsHash = "[^"]*"#npmDepsHash = "'"$npm_hash"'"#' "$path"
# Extract pyodide version
pyodide_version=$(jq -r '.packages["node_modules/pyodide"].version' package-lock.json)
popd
# Update the pyodide version
update-source-version open-webui.frontend "${pyodide_version}" --file="$path" --version-key=pyodideVersion --source-key=pyodide