1 #! /usr/bin/env nix-shell
2 #! nix-shell -i bash -p nix curl jq git gnused gnugrep -I nixpkgs=.
3 # shellcheck shell=bash
7 # Stackage solver to use, LTS or Nightly
8 # (should be capitalized like the display name)
10 # Stackage solver verson, if any. Use latest if empty
12 TMP_TEMPLATE
=update-stackage.XXXXXXX
18 printf "%s" "$1" |
tr '[:upper:]' '[:lower:]'
21 tmpfile
=$
(mktemp
"$TMP_TEMPLATE")
22 tmpfile_new
=$
(mktemp
"$TMP_TEMPLATE")
24 stackage_config
="pkgs/development/haskell-modules/configuration-hackage2nix/stackage.yaml"
26 trap 'rm "${tmpfile}" "${tmpfile_new}"' 0
27 touch "$tmpfile" "$tmpfile_new" # Creating files here so that trap creates no errors.
29 curl
-L -s "https://stackage.org/$(toLower "$SOLVER")${VERSION:+-$VERSION}/cabal.config" >"$tmpfile"
30 old_version
=$
(grep '^# Stackage' $stackage_config |
sed -e 's/.\+ \([A-Za-z]\+ [0-9.-]\+\)$/\1/g')
31 version
="$SOLVER $(sed -rn "s
/^
--.
*http
:..
(www.
)?stackage.org.snapshot.$
(toLower
"$SOLVER")-//p
" "$tmpfile")"
33 if [[ "$old_version" == "$version" ]]; then
34 echo "No new stackage version"
35 exit 0 # Nothing to do
38 echo "Updating Stackage from $old_version to $version."
40 # Create a simple yaml version of the file.
43 -e 's|^constraints:||' \
46 -e '/^with-compiler:/d' \
49 < "${tmpfile}" |
sort --ignore-case >"${tmpfile_new}"
51 cat > $stackage_config << EOF
53 # This file is auto-generated by
54 # maintainers/scripts/haskell/update-stackage.sh
55 default-package-overrides:
58 # Drop restrictions on some tools where we always want the latest version.
61 -e '/ distribution-nixpkgs /d' \
62 -e '/ jailbreak-cabal /d' \
63 -e '/ language-nix /d' \
64 -e '/ hackage-db /d' \
65 -e '/ cabal-install /d' \
66 -e '/ cabal-install-solver /d' \
71 -e '/ ShellCheck /d' \
74 < "${tmpfile_new}" >> $stackage_config
76 # cabal2nix, distribution-nixpkgs, jailbreak-cabal, language-nix: These are our packages and we know what we are doing.
77 # lsp, lsp-types, lsp-test, hie-bios: These are tightly coupled to hls which is not in stackage. They have no rdeps in stackage.
78 # ShellCheck: latest version of command-line dev tool.
79 # Agda: The Agda community is fast-moving; we strive to always include the newest versions of Agda and the Agda packages in nixpkgs.
81 if [[ "${1:-}" == "--do-commit" ]]; then
82 git add
$stackage_config
83 git commit
-F - << EOF
84 haskellPackages: stackage $old_version -> $version
86 This commit has been generated by maintainers/scripts/haskell/update-stackage.sh