maintainers/scripts/haskell: unify pkg set update into single commit

Currently, every package set consists of three commits, generated by
update-hackage.sh, update-stackage.sh and
regenerate-hackage-packages.sh, respectively. This is suboptimal, as it
necessarly causes intermediate states of Nixpkgs where the generated
hackage-packages.nix and all-cabal-hasehs and/or the hackage2nix
configuration files are out of sync. Ideally, running
regenerate-hackage-packages.sh is a no-op for every Nixpkgs revision.

This is achieved by adding a wrapper script, update-package-set.sh,
which runs the individual moving parts and commits the result.
This commit is contained in:
sternenseemann
2025-07-07 16:03:17 +02:00
parent 5e758ae573
commit 34c51b70fb
2 changed files with 54 additions and 7 deletions

View File

@@ -80,13 +80,7 @@ echo "Merging https://github.com/NixOS/nixpkgs/pull/${curr_haskell_updates_pr_nu
gh pr merge --repo NixOS/nixpkgs --merge "$curr_haskell_updates_pr_num"
# Update stackage, Hackage hashes, and regenerate Haskell package set
echo "Updating Stackage..."
./maintainers/scripts/haskell/update-stackage.sh --do-commit
echo "Updating Hackage hashes..."
./maintainers/scripts/haskell/update-hackage.sh --do-commit
echo "Regenerating Hackage packages..."
# Using fast here because after the hackage-update eval errors will likely break the transitive dependencies check.
./maintainers/scripts/haskell/regenerate-hackage-packages.sh --fast --do-commit
./maintainers/scripts/haskell/update-package-set.sh
# Push these new commits to the haskell-updates branch
echo "Pushing commits just created to the remote $push_remote/haskell-updates branch..."

View File

@@ -0,0 +1,53 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash
#! nix-shell -p git -I nixpkgs=.
set -euo pipefail
filesToStage=(
'pkgs/data/misc/hackage/pin.json'
'pkgs/development/haskell-modules/configuration-hackage2nix/stackage.yaml'
'pkgs/development/haskell-modules/hackage-packages.nix'
)
if ! git diff --quiet --cached; then
echo "Please commit staged changes before running $0" >&2
exit 100
fi
if ! git diff --quiet -- "${filesToStage[@]}"; then
echo -n "Please commit your changes to the following files before running $0: " >&2
echo "${filesToStage[@]}" >&2
exit 100
fi
stackage_diff="$(./maintainers/scripts/haskell/update-stackage.sh)"
hackage_diff="$(./maintainers/scripts/haskell/update-hackage.sh)"
readonly stackage_diff hackage_diff
# Prefer Stackage version diff in the commit header, fall back to Hackage
if [[ -n "$stackage_diff" ]]; then
commit_message="haskellPackages: stackage $stackage_diff"
if [[ -n "$hackage_diff" ]]; then
commit_message="$commit_message
all-cabal-hashes: $hackage_diff"
fi
elif [[ -n "$hackage_diff" ]]; then
commit_message="haskellPackages: hackage $hackage_diff
all-cabal-hashes: $hackage_diff"
else
echo "Neither Hackage nor Stackage changed. Nothing to do." >&2
exit 0
fi
commit_message="$commit_message
(generated by maintainers/scripts/haskell/update-package-set.sh)"
# Using fast here because after the hackage-update eval errors will likely break the transitive dependencies check.
./maintainers/scripts/haskell/regenerate-hackage-packages.sh --fast
# A --do-commit flag probably doesn't make much sense
git add -- "${filesToStage[@]}"
git commit -m "$commit_message"