<commit_before>#! /usr/bin/env bash

set -eu -o pipefail

exit_trap()
{
  local lc="$BASH_COMMAND" rc=$?
  test $rc -eq 0 || echo "*** error $rc: $lc"
}

trap exit_trap EXIT

cd "$(dirname "$0")"
cabal2nix=$(git describe --dirty)

cd nixpkgs
git reset -q --hard
git clean -dxf -q
git pull -q
export NIX_PATH=nixpkgs=$PWD
nixpkgs=$(git rev-parse --verify HEAD)
cd ..

cd lts-haskell
git pull -q
ltshaskell=$(git rev-parse --verify HEAD)
cd ..

cd stackage-nightly
git pull -q
stackagenightly=$(git rev-parse --verify HEAD)
cd ..

cd hackage
git pull -q
rm -f preferred-versions
for n in */preferred-versions; do
  cat >>preferred-versions "$n"
  echo >>preferred-versions
done
DIR=$HOME/.cabal/packages/hackage.haskell.org
TAR=$DIR/00-index.tar
TARGZ=$TAR.gz
mkdir -p "$DIR"
rm -f "$TAR" "$TARGZ"
git archive --format=tar -o "$TAR" HEAD
gzip -k "$TAR"
hackage=$(git rev-parse --verify HEAD)
cd ..

stack --verbosity 0 build --test hackage2nix
stack --verbosity 0 exec hackage2nix -- --nixpkgs="$PWD/nixpkgs" +RTS -M6G -RTS

cd nixpkgs
git add pkgs/development/haskell-modules
if [ -n "$(git status --porcelain)" ]; then
  cat <<EOF | git commit -q -F -
hackage-packages.nix: update Haskell package set

This update was generated by hackage2nix $cabal2nix using the following inputs:

  - Nixpkgs: https://github.com/NixOS/nixpkgs/commit/$nixpkgs<commit_msg>update-nixpkgs.sh: don't mention Nixpkgs commit revision in commit<commit_after>#! /usr/bin/env bash

set -eu -o pipefail

exit_trap()
{
  local lc="$BASH_COMMAND" rc=$?
  test $rc -eq 0 || echo "*** error $rc: $lc"
}

trap exit_trap EXIT

cd "$(dirname "$0")"
cabal2nix=$(git describe --dirty)

cd nixpkgs
git reset -q --hard
git clean -dxf -q
git pull -q
export NIX_PATH=nixpkgs=$PWD
nixpkgs=$(git rev-parse --verify HEAD)
cd ..

cd lts-haskell
git pull -q
ltshaskell=$(git rev-parse --verify HEAD)
cd ..

cd stackage-nightly
git pull -q
stackagenightly=$(git rev-parse --verify HEAD)
cd ..

cd hackage
git pull -q
rm -f preferred-versions
for n in */preferred-versions; do
  cat >>preferred-versions "$n"
  echo >>preferred-versions
done
DIR=$HOME/.cabal/packages/hackage.haskell.org
TAR=$DIR/00-index.tar
TARGZ=$TAR.gz
mkdir -p "$DIR"
rm -f "$TAR" "$TARGZ"
git archive --format=tar -o "$TAR" HEAD
gzip -k "$TAR"
hackage=$(git rev-parse --verify HEAD)
cd ..

stack --verbosity 0 build --test hackage2nix
stack --verbosity 0 exec hackage2nix -- --nixpkgs="$PWD/nixpkgs" +RTS -M6G -RTS

cd nixpkgs
git add pkgs/development/haskell-modules
if [ -n "$(git status --porcelain)" ]; then
  cat <<EOF | git commit -q -F -
hackage-packages.nix: update Haskell package set

This update was generated by hackage2nix $cabal2nix using the following inputs:

{'fraction_non_alphanumeric': 0.14835368109507954, 'fraction_numerical': 0.008879023307436182, 'mean_word_length': 3.6701208981001727, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2335778', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1028, 'n_words': 326}