nixpkgs-suyu/maintainers/scripts/haskell/update-hackage.sh
Malte Brandy 7f236bd4b2
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.
2021-05-07 21:58:08 +02:00

35 lines
1.3 KiB
Bash
Executable file

#! /usr/bin/env nix-shell
#! 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.
set -euo pipefail
pin_file=pkgs/data/misc/hackage/pin.json
current_commit="$(jq -r .commit $pin_file)"
old_date="$(jq -r .msg $pin_file | sed 's/Update from Hackage at //')"
git_info="$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/commercialhaskell/all-cabal-hashes/branches/hackage)"
head_commit="$(echo "$git_info" | jq -r .commit.sha)"
commit_msg="$(echo "$git_info" | jq -r .commit.commit.message)"
new_date="$(echo "$commit_msg" | sed 's/Update from Hackage at //')"
if [ "$current_commit" != "$head_commit" ]; then
url="https://github.com/commercialhaskell/all-cabal-hashes/archive/$head_commit.tar.gz"
hash="$(nix-prefetch-url "$url")"
jq -n \
--arg commit "$head_commit" \
--arg hash "$hash" \
--arg url "$url" \
--arg commit_msg "$commit_msg" \
'{commit: $commit, url: $url, sha256: $hash, msg: $commit_msg}' \
> $pin_file
fi
if [[ "${1:-}" == "--do-commit" ]]; then
git add pkgs/data/misc/hackage/pin.json
git commit -F - << EOF
all-cabal-hashes: $old_date -> $new_date
This commit has been generated by maintainers/scripts/haskell/update-hackage.sh
EOF
fi