2020-10-07 13:49:40 +05:00
|
|
|
#!/bin/bash -e
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
2023-11-22 21:49:23 +01:00
|
|
|
## File: install-haskell.sh
|
|
|
|
|
## Desc: Install Haskell, GHCup, Cabal and Stack
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
# Source the helpers for use with the script
|
2020-07-31 11:16:12 +00:00
|
|
|
source $HELPER_SCRIPTS/etc-environment.sh
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2024-03-14 10:53:11 +01:00
|
|
|
# Any nonzero value for non-interactive installation
|
2021-02-19 10:20:15 +03:00
|
|
|
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
|
2022-10-10 13:18:09 +08:00
|
|
|
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1
|
2021-02-19 10:20:15 +03:00
|
|
|
export GHCUP_INSTALL_BASE_PREFIX=/usr/local
|
|
|
|
|
export BOOTSTRAP_HASKELL_GHC_VERSION=0
|
|
|
|
|
ghcup_bin=$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin
|
2023-12-26 12:50:52 +01:00
|
|
|
set_etc_environment_variable "BOOTSTRAP_HASKELL_NONINTERACTIVE" $BOOTSTRAP_HASKELL_NONINTERACTIVE
|
|
|
|
|
set_etc_environment_variable "GHCUP_INSTALL_BASE_PREFIX" $GHCUP_INSTALL_BASE_PREFIX
|
2021-02-19 10:20:15 +03:00
|
|
|
|
|
|
|
|
# Install GHCup
|
2023-07-28 20:18:41 +02:00
|
|
|
curl --proto '=https' --tlsv1.2 -fsSL https://get-ghcup.haskell.org | sh > /dev/null 2>&1 || true
|
2021-02-19 10:20:15 +03:00
|
|
|
export PATH="$ghcup_bin:$PATH"
|
2023-12-26 12:50:52 +01:00
|
|
|
prepend_etc_environment_path $ghcup_bin
|
2021-02-19 10:20:15 +03:00
|
|
|
|
2023-12-29 12:36:27 +01:00
|
|
|
available_versions=$(ghcup list -t ghc -r | grep -v "prerelease" | awk '{print $2}')
|
2020-05-26 18:45:48 +03:00
|
|
|
|
2023-12-29 12:36:27 +01:00
|
|
|
# Install 2 latest Haskell Major.Minor versions
|
|
|
|
|
major_minor_versions=$(echo "$available_versions" | cut -d"." -f 1,2 | uniq | tail -n2)
|
|
|
|
|
for major_minor_version in $major_minor_versions; do
|
|
|
|
|
full_version=$(echo "$available_versions" | grep "$major_minor_version." | tail -n1)
|
|
|
|
|
echo "install ghc version $full_version..."
|
|
|
|
|
ghcup install ghc $full_version
|
|
|
|
|
ghcup set ghc $full_version
|
2020-05-26 18:45:48 +03:00
|
|
|
done
|
|
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
echo "install cabal..."
|
2023-03-21 11:13:46 +01:00
|
|
|
ghcup install cabal latest
|
2020-05-29 14:38:59 +03:00
|
|
|
|
2021-02-19 10:20:15 +03:00
|
|
|
chmod -R 777 $GHCUP_INSTALL_BASE_PREFIX/.ghcup
|
|
|
|
|
ln -s $GHCUP_INSTALL_BASE_PREFIX/.ghcup /etc/skel/.ghcup
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-05-12 11:48:39 -04:00
|
|
|
# Install the latest stable release of haskell stack
|
2023-12-29 12:36:27 +01:00
|
|
|
curl -fsSL https://get.haskellstack.org/ | bash
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2021-04-28 16:51:16 +05:00
|
|
|
invoke_tests "Haskell"
|