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
13do_commit=false
14mark_broken_list_flags=""
15
16for arg in "$@"; do
17 case "$arg" in
18 --do-commit)
19 do_commit=true
20 ;;
21 --no-request-logs)
22 mark_broken_list_flags="$mark_broken_list_flags $arg"
23 ;;
24 *)
25 echo "$0: unknown flag: $arg"
26 exit 100
27 ;;
28 esac
29done
30
31broken_config="pkgs/development/haskell-modules/configuration-hackage2nix/broken.yaml"
32
33tmpfile=$(mktemp)
34trap "rm ${tmpfile}" 0
35
36echo "Remember that you need to manually run 'maintainers/scripts/haskell/hydra-report.hs get-report' sometime before running this script."
37echo "Generating a list of broken builds and displaying for manual confirmation ..."
38maintainers/scripts/haskell/hydra-report.hs mark-broken-list $mark_broken_list_flags | LC_ALL=C.UTF-8 sort --ignore-case > "$tmpfile"
39
40$EDITOR "$tmpfile"
41
42tail -n +3 "$broken_config" >> "$tmpfile"
43
44cat > "$broken_config" << EOF
45# These packages don't compile.
46broken-packages:
47EOF
48
49# clear environment here to avoid things like allowing broken builds in
50LC_ALL=C.UTF-8 sort --ignore-case --unique "$tmpfile" >> "$broken_config"
51clear="env -u HOME -u NIXPKGS_CONFIG"
52$clear maintainers/scripts/haskell/regenerate-hackage-packages.sh
53evalline=$(maintainers/scripts/haskell/hydra-report.hs eval-info)
54
55if $do_commit; then
56git add $broken_config
57git add pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml
58git add pkgs/development/haskell-modules/hackage-packages.nix
59git commit -F - << EOF
60haskellPackages: mark builds failing on hydra as broken
61
62This commit has been generated by maintainers/scripts/haskell/mark-broken.sh based on
63$evalline
64from the haskell-updates jobset on hydra under https://hydra.nixos.org/jobset/nixpkgs/haskell-updates
65EOF
66fi