summary refs log tree commit diff
diff options
context:
space:
mode:
authormaralorn <mail@maralorn.de>2023-04-22 20:15:05 +0200
committermaralorn <mail@maralorn.de>2023-04-23 10:47:36 +0200
commite4b66fa1a121aa9fb9121e0606918f047cd041a2 (patch)
tree383729181b65392e80267b4f7241c490c2fd8c28
parent70ff147052f629874b7b32e9f493d891a45e2599 (diff)
downloadnixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.tar
nixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.tar.gz
nixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.tar.bz2
nixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.tar.lz
nixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.tar.xz
nixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.tar.zst
nixpkgs-e4b66fa1a121aa9fb9121e0606918f047cd041a2.zip
maintainers/scripts/haskell: Integrate transitive-broken into regeneration script
-rwxr-xr-xmaintainers/scripts/haskell/mark-broken.sh2
-rwxr-xr-xmaintainers/scripts/haskell/regenerate-hackage-packages.sh111
-rwxr-xr-xmaintainers/scripts/haskell/regenerate-transitive-broken-packages.sh1
3 files changed, 88 insertions, 26 deletions
diff --git a/maintainers/scripts/haskell/mark-broken.sh b/maintainers/scripts/haskell/mark-broken.sh
index 2111ef52bc0..2624311aac9 100755
--- a/maintainers/scripts/haskell/mark-broken.sh
+++ b/maintainers/scripts/haskell/mark-broken.sh
@@ -32,8 +32,6 @@ EOF
 sort -iu "$tmpfile" >> "$broken_config"
 clear="env -u HOME -u NIXPKGS_CONFIG"
 $clear maintainers/scripts/haskell/regenerate-hackage-packages.sh
-$clear maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
-$clear maintainers/scripts/haskell/regenerate-hackage-packages.sh
 evalline=$(maintainers/scripts/haskell/hydra-report.hs eval-info)
 
 if [[ "${1:-}" == "--do-commit" ]]; then
diff --git a/maintainers/scripts/haskell/regenerate-hackage-packages.sh b/maintainers/scripts/haskell/regenerate-hackage-packages.sh
index 5e6b5a888ad..96a18aa8ed8 100755
--- a/maintainers/scripts/haskell/regenerate-hackage-packages.sh
+++ b/maintainers/scripts/haskell/regenerate-hackage-packages.sh
@@ -1,22 +1,69 @@
 #! /usr/bin/env nix-shell
 #! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=.
 
-# This script is used to regenerate nixpkgs' Haskell package set, using the
-# tool hackage2nix from the nixos/cabal2nix repo. hackage2nix looks at the
-# config files in pkgs/development/haskell-modules/configuration-hackage2nix
-# and generates a Nix expression for package version specified there, using the
-# Cabal files from the Hackage database (available under all-cabal-hashes) and
-# its companion tool cabal2nix.
-#
-# Related scripts are update-hackage.sh, for updating the snapshot of the
-# Hackage database used by hackage2nix, and update-cabal2nix-unstable.sh,
-# for updating the version of hackage2nix used to perform this task.
-#
-# Note that this script doesn't gcroot anything, so it may be broken by an
-# unfortunately timed nix-store --gc.
-
 set -euo pipefail
 
+self=$0
+
+print_help () {
+cat <<END_HELP
+Usage: $self [options]
+
+Options:
+   --do-commit    Commit changes to this file.
+   -f | --fast    Do not update the transitive-broken.yaml file.
+   -h | --help    Show this help.
+
+This script is used to regenerate nixpkgs' Haskell package set, using the
+tool hackage2nix from the nixos/cabal2nix repo. hackage2nix looks at the
+config files in pkgs/development/haskell-modules/configuration-hackage2nix
+and generates a Nix expression for package version specified there, using the
+Cabal files from the Hackage database (available under all-cabal-hashes) and
+its companion tool cabal2nix.
+
+Unless --fast is used, it will then use the generated nix expression by
+running regenerate-transitive-broken-packages.sh which updates the transitive-broken.yaml
+file. Then it re-runs hackage2nix.
+
+Related scripts are update-hackage.sh, for updating the snapshot of the
+Hackage database used by hackage2nix, and update-cabal2nix-unstable.sh,
+for updating the version of hackage2nix used to perform this task.
+
+Note that this script doesn't gcroot anything, so it may be broken by an
+unfortunately timed nix-store --gc.
+
+END_HELP
+}
+
+DO_COMMIT=0
+REGENERATE_TRANSITIVE=1
+
+options=$(getopt -o "fh" -l "help,fast,do-commit" -- "$@")
+
+eval set -- "$options"
+
+while true; do
+   case "$1" in
+      --do-commit)
+         DO_COMMIT=1
+         ;;
+      -f|--fast)
+         REGENERATE_TRANSITIVE=0
+         ;;
+      -h|--help)
+         print_help
+         exit 0
+         ;;
+      --)
+         break;;
+      *)
+         print_help
+         exit 1
+         ;;
+   esac
+   shift
+done
+
 HACKAGE2NIX="${HACKAGE2NIX:-hackage2nix}"
 
 # To prevent hackage2nix fails because of encoding.
@@ -25,14 +72,7 @@ export LC_ALL=C.UTF-8
 
 config_dir=pkgs/development/haskell-modules/configuration-hackage2nix
 
-echo "Obtaining Hackage data"
-extraction_derivation='with import ./. {}; runCommandLocal "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"'
-unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)"
-
-echo "Generating compiler configuration"
-compiler_config="$(nix-build -A haskellPackages.cabal2nix-unstable.compilerConfig --no-out-link)"
-
-echo "Starting hackage2nix to regenerate pkgs/development/haskell-modules/hackage-packages.nix ..."
+run_hackage2nix() {
 "$HACKAGE2NIX" \
    --hackage "$unpacked_hackage" \
    --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \
@@ -42,8 +82,33 @@ echo "Starting hackage2nix to regenerate pkgs/development/haskell-modules/hackag
    --config "$config_dir/stackage.yaml" \
    --config "$config_dir/broken.yaml" \
    --config "$config_dir/transitive-broken.yaml"
+}
+
+echo "Obtaining Hackage data …"
+extraction_derivation='with import ./. {}; runCommandLocal "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"'
+unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)"
+
+echo "Generating compiler configuration …"
+compiler_config="$(nix-build -A haskellPackages.cabal2nix-unstable.compilerConfig --no-out-link)"
+
+echo "Running hackage2nix to regenerate pkgs/development/haskell-modules/hackage-packages.nix …"
+run_hackage2nix
+
+if [[ "$REGENERATE_TRANSITIVE" -eq 1 ]]; then
+
+echo "Regenerating transitive-broken.yaml … (pass --fast to $self to skip this step)"
+
+maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
+
+echo "Running hackage2nix again to reflect changes in transitive-broken.yaml …"
+
+run_hackage2nix
+
+fi
+
 
-if [[ "${1:-}" == "--do-commit" ]]; then
+if [[ "$DO_COMMIT" -eq 1 ]]; then
+git add pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml
 git add pkgs/development/haskell-modules/hackage-packages.nix
 git commit -F - << EOF
 haskellPackages: regenerate package set based on current config
diff --git a/maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh b/maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
index 69455bfb687..5a17b051835 100755
--- a/maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
+++ b/maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
@@ -11,5 +11,4 @@ cat > $config_file << EOF
 dont-distribute-packages:
 EOF
 
-echo "Regenerating list of transitive broken packages ..."
 nix-instantiate --eval --option restrict-eval true -I . --strict --json maintainers/scripts/haskell/transitive-broken-packages.nix | jq -r . | LC_ALL=C.UTF-8 sort -i >> $config_file