git.iko.soy/typeable/cabal2nix
on v2.15.0 help sign in
typeable/cabal2nix/update-stackage.sh
54 lines 1.6 kB history raw
1#! /usr/bin/env bash
3set -eu -o pipefail
5cd "$(dirname "$0")"
7tmpfile=$(mktemp "update-stackage.XXXXXXX")
8# shellcheck disable=SC2064
9trap "rm ${tmpfile} ${tmpfile}.new" 0
11curl -L -s "https://stackage.org/lts/cabal.config" >"$tmpfile"
12version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.lts-//p" "$tmpfile")
14# Create a simple yaml version of the file.
15sed -r \
16 -e '/^--/d' \
17 -e 's|^constraints:||' \
18 -e 's|^ +| - |' \
19 -e 's|,$||' \
20 -e '/installed$/d' \
21 -e '/^$/d' \
22 < "${tmpfile}" | sort --ignore-case >"${tmpfile}.new"
24# Drop restrictions on some tools where we always want the latest version.
25sed -r \
26 -e '/ cabal-install /d' \
27 -e '/ cabal2nix /d' \
28 -e '/ distribution-nixpkgs /d' \
29 -e '/ git-annex /d' \
30 -e '/ hindent /d' \
31 -e '/ hledger/d' \
32 -e '/ hlint /d' \
33 -e '/ hoogle /d' \
34 -e '/ hopenssl /d' \
35 -e '/ jailbreak-cabal /d' \
36 -e '/ json-autotype/d' \
37 -e '/ lambdabot-core /d' \
38 -e '/ lambdabot-irc-plugins /d' \
39 -e '/ language-nix /d' \
40 -e '/ shake /d' \
41 -e '/ ShellCheck /d' \
42 -e '/ stack /d' \
43 -e '/ weeder /d' \
44 < "${tmpfile}.new" > "${tmpfile}"
46# Drop the previous configuration ...
47# shellcheck disable=SC1004
48sed -e '/# LTS Haskell/,/^$/c \TODO\
49' -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml
51# ... and replace it with the new one.
52sed -e "/TODO/r $tmpfile" \
53 -e "s/TODO/ # LTS Haskell $version/" \
54 -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml