at 22.05-pre 1.7 kB view raw
1#! /usr/bin/env nix-shell 2#! nix-shell -i bash -p nix curl jq nix-prefetch-github git gnused gnugrep -I nixpkgs=. 3 4set -eu -o pipefail 5 6tmpfile=$(mktemp "update-stackage.XXXXXXX") 7# shellcheck disable=SC2064 8 9stackage_config="pkgs/development/haskell-modules/configuration-hackage2nix/stackage.yaml" 10 11trap "rm ${tmpfile} ${tmpfile}.new" 0 12touch "$tmpfile" "$tmpfile.new" # Creating files here so that trap creates no errors. 13 14curl -L -s "https://stackage.org/lts/cabal.config" >"$tmpfile" 15old_version=$(grep "# Stackage" $stackage_config | sed -E 's/.*([0-9]{2}\.[0-9]+)/\1/') 16version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.lts-//p" "$tmpfile") 17 18if [[ "$old_version" == "$version" ]]; then 19 echo "No new stackage version" 20 exit 0 # Nothing to do 21fi 22 23echo "Updating Stackage LTS from $old_version to $version." 24 25# Create a simple yaml version of the file. 26sed -r \ 27 -e '/^--/d' \ 28 -e 's|^constraints:||' \ 29 -e 's|^ +| - |' \ 30 -e 's|,$||' \ 31 -e '/installed$/d' \ 32 -e '/^$/d' \ 33 < "${tmpfile}" | sort --ignore-case >"${tmpfile}.new" 34 35cat > $stackage_config << EOF 36# Stackage LTS $version 37# This file is auto-generated by 38# maintainers/scripts/haskell/update-stackage.sh 39default-package-overrides: 40EOF 41 42# Drop restrictions on some tools where we always want the latest version. 43sed -r \ 44 -e '/ cabal2nix /d' \ 45 -e '/ distribution-nixpkgs /d' \ 46 -e '/ jailbreak-cabal /d' \ 47 -e '/ language-nix /d' \ 48 < "${tmpfile}.new" >> $stackage_config 49 50if [[ "${1:-}" == "--do-commit" ]]; then 51git add $stackage_config 52git commit -F - << EOF 53haskellPackages: stackage-lts $old_version -> $version 54 55This commit has been generated by maintainers/scripts/haskell/update-stackage.sh 56EOF 57fi