From 13517dc5da5ff154b3fe221007bf98012993033b Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 14 Feb 2025 20:44:14 +0100 Subject: [PATCH] maintainers/scripts/haskell: add unbreak.nu script The new script runs through all packages marked as broken in broken.yaml, tries to build them, and removes them from the file if they do. --- maintainers/scripts/haskell/unbreak.nu | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 maintainers/scripts/haskell/unbreak.nu diff --git a/maintainers/scripts/haskell/unbreak.nu b/maintainers/scripts/haskell/unbreak.nu new file mode 100755 index 000000000000..b3604b17d60b --- /dev/null +++ b/maintainers/scripts/haskell/unbreak.nu @@ -0,0 +1,31 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i nu -p nushell flock gnused -I nixpkgs=. + +# This script tests to build all packages listed in broken.yaml, expecting a build failure. +# It will remove all packages that build fine from the list. + +# Attention: For unknown reasons, the script can't be easily cancelled and needs to be killed manually if it shouldn't run to completion. + +use std log + +let broken_config = "pkgs/development/haskell-modules/configuration-hackage2nix/broken.yaml" + +def is-broken [package : string]: nothing -> bool { + let res = with-env { NIXPKGS_ALLOW_BROKEN: "1" } { + # rather high timeout of half an hour, just to prevent never-ending builds + ^nix-build --no-out-link -j 1 --cores 1 --timeout 1800 -A $"haskellPackages.($package)" | complete + } + if $res.exit_code == 0 { + log warning $"($package) is not broken anymore!" + return false + } else { + log info $"($package) is still broken." + log debug $"($package) build log:\n($res.stderr)" + return true + } +} + +def main [] { + $broken_config | open | get broken-packages + | par-each {|package| if not (is-broken $package) { ^flock -x $broken_config -c $"sed -i -e '/^ - ($package) /d' ($broken_config)" }} +}