From c0e615d0dda4ffc3fa0ffcf32056fc0e224ac1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20K=C3=B6nig?= Date: Fri, 5 Jun 2026 16:12:56 +0200 Subject: [PATCH] melos: fix hashing in update script The current update script hashes the archive instead of the contents and therefore fails (see the [nixpkgs-update logs][0]). This changes that behavior to hash the unpacked contents before anything is altered. [0]: https://nixpkgs-update-logs.nix-community.org/melos/2026-06-03.log (cherry picked from commit 175f077ef5abfde25f19926a1983567a2e27a141) --- pkgs/by-name/me/melos/update.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/me/melos/update.sh b/pkgs/by-name/me/melos/update.sh index dc0514431d57..b624d730ace3 100755 --- a/pkgs/by-name/me/melos/update.sh +++ b/pkgs/by-name/me/melos/update.sh @@ -55,6 +55,14 @@ tar -xzf "$archive_path" -C "$tmpdir" extracted_dir=$(tar -tzf "$archive_path" | head -1 | cut -d/ -f1) source_dir="$tmpdir/$extracted_dir" +# Compute the hash from the downloaded and unpacked archive +echo "Computing source hash..." >&2 +new_hash=$(nix-hash --type sha256 --sri "$source_dir") +if [ -z "$new_hash" ]; then + echo "Error: Failed to compute source hash" >&2 + exit 1 +fi + echo "Generating pubspec.lock..." >&2 cd "$source_dir" dart pub get > /dev/null 2>&1 @@ -62,15 +70,6 @@ dart pub get > /dev/null 2>&1 echo "Converting to JSON..." >&2 yq eval --output-format=json --prettyPrint pubspec.lock > "$tmpdir/pubspec.lock.json" -# Compute the hash from the downloaded archive -echo "Computing source hash..." >&2 -nix_hash=$(nix-hash --flat --base32 --type sha256 "$archive_path") -if [ -z "$nix_hash" ]; then - echo "Error: Failed to compute source hash" >&2 - exit 1 -fi -new_hash="sha256-$(nix-hash --to-sri --type sha256 "$nix_hash")" - cp "$tmpdir/pubspec.lock.json" "$script_dir/pubspec.lock.json" echo "Updated pubspec.lock.json" >&2