···11+#! /usr/bin/env nix-shell
22+#! nix-shell -i nu -p nushell flock gnused -I nixpkgs=.
33+44+# This script tests to build all packages listed in broken.yaml, expecting a build failure.
55+# It will remove all packages that build fine from the list.
66+77+# Attention: For unknown reasons, the script can't be easily cancelled and needs to be killed manually if it shouldn't run to completion.
88+99+use std log
1010+1111+let broken_config = "pkgs/development/haskell-modules/configuration-hackage2nix/broken.yaml"
1212+1313+def is-broken [package : string]: nothing -> bool {
1414+ let res = with-env { NIXPKGS_ALLOW_BROKEN: "1" } {
1515+ # rather high timeout of half an hour, just to prevent never-ending builds
1616+ ^nix-build --no-out-link -j 1 --cores 1 --timeout 1800 -A $"haskellPackages.($package)" | complete
1717+ }
1818+ if $res.exit_code == 0 {
1919+ log warning $"($package) is not broken anymore!"
2020+ return false
2121+ } else {
2222+ log info $"($package) is still broken."
2323+ log debug $"($package) build log:\n($res.stderr)"
2424+ return true
2525+ }
2626+}
2727+2828+def main [] {
2929+ $broken_config | open | get broken-packages
3030+ | par-each {|package| if not (is-broken $package) { ^flock -x $broken_config -c $"sed -i -e '/^ - ($package) /d' ($broken_config)" }}
3131+}