2020-05-04 01:01:57 +02:00
|
|
|
#! /usr/bin/env nix-shell
|
2021-05-05 22:38:46 +02:00
|
|
|
#! nix-shell -i bash -p coreutils haskellPackages.cabal2nix-unstable git nix -I nixpkgs=.
|
2020-05-04 01:01:57 +02:00
|
|
|
|
2021-05-09 01:01:21 +02:00
|
|
|
# This script is used to regenerate nixpkgs' Haskell package set, using the
|
|
|
|
# tool hackage2nix from the nixos/cabal2nix repo. 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.
|
2020-05-04 01:01:57 +02:00
|
|
|
#
|
|
|
|
# Related scripts are update-hackage.sh, for updating the snapshot of the
|
2021-05-04 13:38:29 +02:00
|
|
|
# Hackage database used by hackage2nix, and update-cabal2nix-unstable.sh,
|
2020-05-04 01:01:57 +02:00
|
|
|
# for updating the version of hackage2nix used to perform this task.
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2021-06-05 16:08:32 +02:00
|
|
|
HACKAGE2NIX="${HACKAGE2NIX:-hackage2nix}"
|
|
|
|
|
2021-05-09 01:01:21 +02:00
|
|
|
# To prevent hackage2nix fails because of encoding.
|
|
|
|
# See: https://github.com/NixOS/nixpkgs/pull/122023
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
|
2022-03-11 14:32:36 +01:00
|
|
|
extraction_derivation='with import ./. {}; runCommandLocal "unpacked-cabal-hashes" { } "tar xf ${all-cabal-hashes} --strip-components=1 --one-top-level=$out"'
|
2021-05-05 22:38:46 +02:00
|
|
|
unpacked_hackage="$(nix-build -E "$extraction_derivation" --no-out-link)"
|
|
|
|
config_dir=pkgs/development/haskell-modules/configuration-hackage2nix
|
2020-05-04 01:01:57 +02:00
|
|
|
|
2021-05-09 01:01:21 +02:00
|
|
|
echo "Starting hackage2nix to regenerate pkgs/development/haskell-modules/hackage-packages.nix ..."
|
2021-06-05 16:08:32 +02:00
|
|
|
"$HACKAGE2NIX" \
|
2021-05-05 22:38:46 +02:00
|
|
|
--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"
|
2021-05-03 22:52:32 +02:00
|
|
|
|
|
|
|
if [[ "${1:-}" == "--do-commit" ]]; then
|
2021-05-04 13:43:44 +02:00
|
|
|
git add pkgs/development/haskell-modules/hackage-packages.nix
|
|
|
|
git commit -F - << EOF
|
2021-06-06 18:48:42 +02:00
|
|
|
haskellPackages: regenerate package set based on current config
|
2021-05-04 13:43:44 +02:00
|
|
|
|
|
|
|
This commit has been generated by maintainers/scripts/haskell/regenerate-hackage-packages.sh
|
|
|
|
EOF
|
2021-05-03 22:52:32 +02:00
|
|
|
fi
|
2021-05-09 01:01:21 +02:00
|
|
|
|
|
|
|
echo "Regeneration of hackage-packages.nix finished."
|