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