git.iko.soy/typeable/cabal2nix
on v2.15.1 help sign in
typeable/cabal2nix/update-stackage.sh
53 lines 1.5 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 '/ cabal2spec /d' \
29 -e '/ distribution-nixpkgs /d' \
30 -e '/ git-annex /d' \
31 -e '/ hindent /d' \
32 -e '/ hledger/d' \
33 -e '/ hlint /d' \
34 -e '/ hoogle /d' \
35 -e '/ hopenssl /d' \
36 -e '/ jailbreak-cabal /d' \
37 -e '/ json-autotype/d' \
38 -e '/ language-nix /d' \
39 -e '/ shake /d' \
40 -e '/ ShellCheck /d' \
41 -e '/ stack /d' \
42 -e '/ weeder /d' \
43 < "${tmpfile}.new" > "${tmpfile}"
45# Drop the previous configuration ...
46# shellcheck disable=SC1004
47sed -e '/ # LTS Haskell/,/^$/c \TODO\
48' -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml
50# ... and replace it with the new one.
51sed -e "/TODO/r $tmpfile" \
52 -e "s/TODO/ # LTS Haskell $version/" \
53 -i nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml