0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

hackage2nix: Split configuration, auto disable hydra builds

We split configuration-hackage2nix.yaml into multiple files.  We bump
cabal2nix-unstable to get support for multiple config files in
hackage2nix.

* The file main.yaml is only supposed to be edited by humans.
* The file stackage.yaml is only supposed to be updated by the
  update-stackage.sh
* The file broken.yaml can be edited by humans, but probably future
  helpers will want to insert broken packages into this file based on
  hydra reports.
* The file transitive-broken.yaml is newly introduced to be generated
  by regenerate-transitive-broken-packages.sh

regenerate-transitive-broken-packages.sh makes a nix query (in
transitive-broken-packages.nix) which evaluates all haskellPackages
once with and once without "allowBroken" this way it get's a list of
packages which are broken by some transitive dependency, but does not
disable packages which have eval errors not caused by a broken package.
This commit is contained in:
Malte Brandy 2021-05-05 22:38:46 +02:00
parent d75130019b
commit 7f236bd4b2
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
10 changed files with 3309 additions and 3175 deletions

View file

@ -1,9 +1,9 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable -I nixpkgs=.
#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=.
# This script is used to regenerate nixpkgs' Haskell package set, using a tool
# called hackage2nix. hackage2nix looks at
# pkgs/development/haskell-modules/configuration-hackage2nix.yaml and generates
# called hackage2nix. hackage2nix looks at the config files in
# pkgs/development/haskell-modules/configuration-hackage2nix and generates
# a Nix expression for package version specified there, using the Cabal files
# from the Hackage database (available under all-cabal-hashes) and its
# companion tool cabal2nix.
@ -14,10 +14,18 @@
set -euo pipefail
extractionDerivation='with import ./. {}; runCommand "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"'
unpacked_hackage="$(nix-build -E "$extractionDerivation" --no-out-link)"
extraction_derivation='with import ./. {}; runCommand "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"'
unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)"
config_dir=pkgs/development/haskell-modules/configuration-hackage2nix
hackage2nix --hackage "$unpacked_hackage" --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) --nixpkgs "$PWD" --config pkgs/development/haskell-modules/configuration-hackage2nix.yaml
hackage2nix \
--hackage "$unpacked_hackage" \
--preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \
--nixpkgs "$PWD" \
--config "$config_dir/main.yaml" \
--config "$config_dir/stackage.yaml" \
--config "$config_dir/broken.yaml" \
--config "$config_dir/transitive-broken.yaml"
if [[ "${1:-}" == "--do-commit" ]]; then
git add pkgs/development/haskell-modules/hackage-packages.nix

View file

@ -0,0 +1,3 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils nix gnused -I nixpkgs=.
echo -e $(nix-instantiate --eval --strict maintainers/scripts/haskell/transitive-broken-packages.nix) | sed 's/\"//' > pkgs/development/haskell-modules/configuration-hackage2nix/transitive-broken.yaml

View file

@ -0,0 +1,21 @@
let
nixpkgs = import ../../..;
inherit (nixpkgs {}) pkgs lib;
getEvaluating = x:
builtins.attrNames (
lib.filterAttrs (
_: v: (builtins.tryEval (v.outPath or null)).success && lib.isDerivation v && !v.meta.broken
) x
);
brokenDeps = lib.subtractLists
(getEvaluating pkgs.haskellPackages)
(getEvaluating (nixpkgs { config.allowBroken = true; }).haskellPackages);
in
''
# This file is automatically generated by
# maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
# It is supposed to list all haskellPackages that cannot evaluate because they
# depend on a dependency marked as broken.
dont-distribute-packages:
${lib.concatMapStringsSep "\n" (x: " - ${x}") brokenDeps}
''

View file

@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix curl jq nix-prefetch-github -I nixpkgs=.
#! nix-shell -i bash -p nix curl jq nix-prefetch-github git gnused -I nixpkgs=.
# See regenerate-hackage-packages.sh for details on the purpose of this script.

View file

@ -1,17 +1,18 @@
#! /usr/bin/env bash
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix curl jq nix-prefetch-github git gnused gnugrep -I nixpkgs=.
set -eu -o pipefail
tmpfile=$(mktemp "update-stackage.XXXXXXX")
# shellcheck disable=SC2064
config_file="pkgs/development/haskell-modules/configuration-hackage2nix.yaml"
stackage_config="pkgs/development/haskell-modules/configuration-hackage2nix/stackage.yaml"
trap "rm ${tmpfile} ${tmpfile}.new" 0
touch "$tmpfile" "$tmpfile.new" # Creating files here so that trap creates no errors.
curl -L -s "https://stackage.org/nightly/cabal.config" >"$tmpfile"
old_version=$(grep " # Stackage Nightly" $config_file | sed -E 's/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/')
old_version=$(grep "# Stackage Nightly" $stackage_config | sed -E 's/.*([0-9]{4}-[0-9]{2}-[0-9]{2}).*/\1/')
version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.nightly-//p" "$tmpfile")
if [[ "$old_version" == "$version" ]]; then
@ -29,6 +30,13 @@ sed -r \
-e '/^$/d' \
< "${tmpfile}" | sort --ignore-case >"${tmpfile}.new"
cat > $stackage_config << EOF
# Stackage Nightly $version
# This file is auto-generated by
# maintainers/scripts/haskell/update-stackage.sh
default-package-overrides:
EOF
# Drop restrictions on some tools where we always want the latest version.
sed -r \
-e '/ cabal-install /d' \
@ -48,17 +56,7 @@ sed -r \
-e '/ ShellCheck /d' \
-e '/ stack /d' \
-e '/ weeder /d' \
< "${tmpfile}.new" > "${tmpfile}"
# Drop the previous configuration ...
# shellcheck disable=SC1004
sed -e '/ # Stackage Nightly/,/^$/c \TODO\
' -i $config_file
# ... and replace it with the new one.
sed -e "/TODO/r $tmpfile" \
-e "s/TODO/ # Stackage Nightly $version/" \
-i $config_file
< "${tmpfile}.new" >> $stackage_config
if [[ "${1:-}" == "--do-commit" ]]; then
git add $config_file