···1#! /usr/bin/env nix-shell
2#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=.
34-# 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.
1718-set -euo pipefail
000000000000000000000000000000000000000000000000000000000001920HACKAGE2NIX="${HACKAGE2NIX:-hackage2nix}"
21···2526config_dir=pkgs/development/haskell-modules/configuration-hackage2nix
2728-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 ..."
36"$HACKAGE2NIX" \
37 --hackage "$unpacked_hackage" \
38 --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \
···42 --config "$config_dir/stackage.yaml" \
43 --config "$config_dir/broken.yaml" \
44 --config "$config_dir/transitive-broken.yaml"
04546-if [[ "${1:-}" == "--do-commit" ]]; then
00000000000000000000000047git add pkgs/development/haskell-modules/hackage-packages.nix
48git commit -F - << EOF
49haskellPackages: regenerate package set based on current config
···1#! /usr/bin/env nix-shell
2#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=.
34+set -euo pipefail
00000000000056+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
6667HACKAGE2NIX="${HACKAGE2NIX:-hackage2nix}"
68···7273config_dir=pkgs/development/haskell-modules/configuration-hackage2nix
7475+run_hackage2nix() {
000000076"$HACKAGE2NIX" \
77 --hackage "$unpacked_hackage" \
78 --preferred-versions <(for n in "$unpacked_hackage"/*/preferred-versions; do cat "$n"; echo; done) \
···82 --config "$config_dir/stackage.yaml" \
83 --config "$config_dir/broken.yaml" \
84 --config "$config_dir/transitive-broken.yaml"
85+}
8687+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
112git add pkgs/development/haskell-modules/hackage-packages.nix
113git commit -F - << EOF
114haskellPackages: regenerate package set based on current config