1#! /usr/bin/env nix-shell
2#! nix-shell -i bash -p coreutils git -I nixpkgs=.
3
4# This script uses the data pulled with
5# maintainers/scripts/haskell/hydra-report.hs get-report to produce a list of
6# failing builds that get written to the hackage2nix config. Then
7# hackage-packages.nix gets regenerated and transitive-broken packages get
8# marked as dont-distribute in the config as well.
9# This should disable builds for most failing jobs in the haskell-updates jobset.
10
11set -euo pipefail
12
13broken_config="pkgs/development/haskell-modules/configuration-hackage2nix/broken.yaml"
14
15tmpfile=$(mktemp)
16trap "rm ${tmpfile}" 0
17
18echo "Remember that you need to manually run 'maintainers/scripts/haskell/hydra-report.hs get-report' sometime before running this script."
19echo "Generating a list of broken builds and displaying for manual confirmation ..."
20maintainers/scripts/haskell/hydra-report.hs mark-broken-list | sort -i > "$tmpfile"
21
22$EDITOR "$tmpfile"
23
24tail -n +3 "$broken_config" >> "$tmpfile"
25
26cat > "$broken_config" << EOF
27broken-packages:
28 # These packages don't compile.
29EOF
30
31# clear environment here to avoid things like allowing broken builds in
32sort -iu "$tmpfile" >> "$broken_config"
33clear="env -u HOME -u NIXPKGS_CONFIG"
34$clear maintainers/scripts/haskell/regenerate-hackage-packages.sh
35$clear maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
36$clear maintainers/scripts/haskell/regenerate-hackage-packages.sh
37
38if [[ "${1:-}" == "--do-commit" ]]; then
39git add $broken_config
40git add pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml
41git add pkgs/development/haskell-modules/hackage-packages.nix
42git commit -F - << EOF
43haskellPackages: mark builds failing on hydra as broken
44
45This commit has been generated by maintainers/scripts/haskell/mark-broken.sh
46EOF
47fi