maintainers/scripts/haskell: Integrate transitive-broken into regeneration script

maralorn e4b66fa1 70ff1470

+88 -26
-2
maintainers/scripts/haskell/mark-broken.sh
··· 32 32 sort -iu "$tmpfile" >> "$broken_config" 33 33 clear="env -u HOME -u NIXPKGS_CONFIG" 34 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 35 evalline=$(maintainers/scripts/haskell/hydra-report.hs eval-info) 38 36 39 37 if [[ "${1:-}" == "--do-commit" ]]; then
+88 -23
maintainers/scripts/haskell/regenerate-hackage-packages.sh
··· 1 1 #! /usr/bin/env nix-shell 2 2 #! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=. 3 3 4 - # This script is used to regenerate nixpkgs' Haskell package set, using the 5 - # tool hackage2nix from the nixos/cabal2nix repo. hackage2nix looks at the 6 - # config files in pkgs/development/haskell-modules/configuration-hackage2nix 7 - # and generates a Nix expression for package version specified there, using the 8 - # Cabal files from the Hackage database (available under all-cabal-hashes) and 9 - # its companion tool cabal2nix. 10 - # 11 - # Related scripts are update-hackage.sh, for updating the snapshot of the 12 - # Hackage database used by hackage2nix, and update-cabal2nix-unstable.sh, 13 - # for updating the version of hackage2nix used to perform this task. 14 - # 15 - # Note that this script doesn't gcroot anything, so it may be broken by an 16 - # unfortunately timed nix-store --gc. 4 + set -euo pipefail 17 5 18 - set -euo pipefail 6 + self=$0 7 + 8 + print_help () { 9 + cat <<END_HELP 10 + Usage: $self [options] 11 + 12 + Options: 13 + --do-commit Commit changes to this file. 14 + -f | --fast Do not update the transitive-broken.yaml file. 15 + -h | --help Show this help. 16 + 17 + This script is used to regenerate nixpkgs' Haskell package set, using the 18 + tool hackage2nix from the nixos/cabal2nix repo. hackage2nix looks at the 19 + config files in pkgs/development/haskell-modules/configuration-hackage2nix 20 + and generates a Nix expression for package version specified there, using the 21 + Cabal files from the Hackage database (available under all-cabal-hashes) and 22 + its companion tool cabal2nix. 23 + 24 + Unless --fast is used, it will then use the generated nix expression by 25 + running regenerate-transitive-broken-packages.sh which updates the transitive-broken.yaml 26 + file. Then it re-runs hackage2nix. 27 + 28 + Related scripts are update-hackage.sh, for updating the snapshot of the 29 + Hackage database used by hackage2nix, and update-cabal2nix-unstable.sh, 30 + for updating the version of hackage2nix used to perform this task. 31 + 32 + Note that this script doesn't gcroot anything, so it may be broken by an 33 + unfortunately timed nix-store --gc. 34 + 35 + END_HELP 36 + } 37 + 38 + DO_COMMIT=0 39 + REGENERATE_TRANSITIVE=1 40 + 41 + options=$(getopt -o "fh" -l "help,fast,do-commit" -- "$@") 42 + 43 + eval set -- "$options" 44 + 45 + while true; do 46 + case "$1" in 47 + --do-commit) 48 + DO_COMMIT=1 49 + ;; 50 + -f|--fast) 51 + REGENERATE_TRANSITIVE=0 52 + ;; 53 + -h|--help) 54 + print_help 55 + exit 0 56 + ;; 57 + --) 58 + break;; 59 + *) 60 + print_help 61 + exit 1 62 + ;; 63 + esac 64 + shift 65 + done 19 66 20 67 HACKAGE2NIX="${HACKAGE2NIX:-hackage2nix}" 21 68 ··· 25 72 26 73 config_dir=pkgs/development/haskell-modules/configuration-hackage2nix 27 74 28 - echo "Obtaining Hackage data" 29 - extraction_derivation='with import ./. {}; runCommandLocal "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"' 30 - unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)" 31 - 32 - echo "Generating compiler configuration" 33 - compiler_config="$(nix-build -A haskellPackages.cabal2nix-unstable.compilerConfig --no-out-link)" 34 - 35 - echo "Starting hackage2nix to regenerate pkgs/development/haskell-modules/hackage-packages.nix ..." 75 + run_hackage2nix() { 36 76 "$HACKAGE2NIX" \ 37 77 --hackage "$unpacked_hackage" \ 38 78 --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \ ··· 42 82 --config "$config_dir/stackage.yaml" \ 43 83 --config "$config_dir/broken.yaml" \ 44 84 --config "$config_dir/transitive-broken.yaml" 85 + } 45 86 46 - if [[ "${1:-}" == "--do-commit" ]]; then 87 + echo "Obtaining Hackage data …" 88 + extraction_derivation='with import ./. {}; runCommandLocal "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"' 89 + unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)" 90 + 91 + echo "Generating compiler configuration …" 92 + compiler_config="$(nix-build -A haskellPackages.cabal2nix-unstable.compilerConfig --no-out-link)" 93 + 94 + echo "Running hackage2nix to regenerate pkgs/development/haskell-modules/hackage-packages.nix …" 95 + run_hackage2nix 96 + 97 + if [[ "$REGENERATE_TRANSITIVE" -eq 1 ]]; then 98 + 99 + echo "Regenerating transitive-broken.yaml … (pass --fast to $self to skip this step)" 100 + 101 + maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh 102 + 103 + echo "Running hackage2nix again to reflect changes in transitive-broken.yaml …" 104 + 105 + run_hackage2nix 106 + 107 + fi 108 + 109 + 110 + if [[ "$DO_COMMIT" -eq 1 ]]; then 111 + git add pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml 47 112 git add pkgs/development/haskell-modules/hackage-packages.nix 48 113 git commit -F - << EOF 49 114 haskellPackages: regenerate package set based on current config
-1
maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
··· 11 11 dont-distribute-packages: 12 12 EOF 13 13 14 - echo "Regenerating list of transitive broken packages ..." 15 14 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