ente-web: create update script

This commit is contained in:
Kermina Awad
2026-03-20 12:38:04 -04:00
parent 5f3c5236ec
commit 8e20a55ca6
+52 -7
View File
@@ -12,7 +12,7 @@
wasm-pack,
yarnConfigHook,
yarnBuildHook,
nix-update-script,
writeScript,
extraBuildEnv ? { },
# This package contains serveral sub-applications. This specifies which of them you want to build.
enteApp ? "photos",
@@ -106,12 +106,57 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';
passthru.updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"photos-v(.*)"
];
};
passthru.updateScript = writeScript "update-ente-web" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils nix-update gnugrep gnused curl
set -eu -o pipefail
# Assume the current working directory is Nixpkgs
file_path="./pkgs/by-name/en/ente-web/package.nix"
# Extract version, then update
old_version=$(grep -oP 'version = "\K[^"]+' "$file_path" | head -n1)
if [[ -z "$old_version" ]]; then
echo "Failed to extract old version from $file_path"
exit 1
fi
nix-update ente-web --version-regex 'photos-v(.*)'
new_version=$(grep -oP 'version = "\K[^"]+' "$file_path" | head -n1)
if [[ -z "$new_version" ]]; then
echo "Failed to extract new version from $file_path"
exit 1
fi
if [[ "$old_version" == "$new_version" ]]; then
echo "No update"
exit 0
fi
echo "Updated to version $new_version, checking wasm-bindgen..."
# Fetch Cargo.lock from GitHub instead of cloning repository
cargo_lock_url="https://raw.githubusercontent.com/ente-io/ente/photos-v$new_version/web/packages/wasm/Cargo.lock"
wasm_bindgen_version=$(curl -s "$cargo_lock_url" | tr -d '\r' | grep -A1 '^name = "wasm-bindgen"$' | grep -oP 'version = "\K[^"]+' | head -n1)
if [[ -z "$wasm_bindgen_version" ]]; then
echo "Failed to find wasm-bindgen version in Cargo.lock from $cargo_lock_url"
exit 1
fi
echo "Found wasm-bindgen version: $wasm_bindgen_version"
# Construct new attribute name
wasm_bindgen_attr="wasm-bindgen-cli_''${wasm_bindgen_version//./_}"
# Replace old attribute name in file
sed -i "s/wasm-bindgen-cli_[0-9_]\+/$wasm_bindgen_attr/g" "$file_path"
echo "Successfully updated wasm-bindgen-cli to $wasm_bindgen_attr"
'';
meta = {
description = "Ente application web frontends";