Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/haskell/install.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash

GHC_VERSION="${GHCVERSION:-"latest"}"
CABAL_VERSION="${CABALVERSION:-"latest"}"
INCLUDE_STACK="${INSTALLSTACK:-"true"}"
ADJUST_BASHRC="${ADJUSTBASH:-"true"}"
CABAL_VERSION="${CABALVERSION:-"latest"}"
INCLUDE_STACK="${INSTALLSTACK:-"true"}"
ADJUST_BASHRC="${ADJUSTBASH:-"true"}"

INSTALL_STACK_GHCUP_HOOK="${INSTALLSTACKGHCUPHOOK:-"true"}"

# Clean up
# Clean up
rm -rf /var/lib/apt/lists/*

if [ "$(id -u)" -ne 0 ]; then
Expand All @@ -17,7 +17,7 @@ fi

# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
if ! dpkg -s "$@" >/dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
Expand All @@ -30,27 +30,34 @@ check_packages curl build-essential libffi-dev libffi8ubuntu1 libgmp-dev libgmp1

export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
export GHCUP_USE_XDG_DIRS=1
export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION}"
export BOOTSTRAP_HASKELL_GHC_VERSION="${GHC_VERSION}"
export BOOTSTRAP_HASKELL_CABAL_VERSION="${CABAL_VERSION}"
export BOOTSTRAP_HASKELL_DOWNLOADER="curl"

if [[ "${INCLUDE_STACK}" = "false" ]] ; then
if [[ "${INCLUDE_STACK}" = "false" ]]; then
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK="true"
fi
if [[ "${ADJUST_BASH}" = "true" ]] ; then
if [[ "${ADJUST_BASH}" = "true" ]]; then
export BOOTSTRAP_HASKELL_ADJUST_BASHRC="true"
fi
if [[ "${INSTALL_STACK_GHCUP_HOOK}" = "false" ]] ; then
if [[ "${INSTALL_STACK_GHCUP_HOOK}" = "false" ]]; then
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK="true"
fi

# The installation script is designed to be run by the non-root user
# The files need to be in the remote user's ~/ home directory
ROOT_HOME="${HOME}"
export HOME="${_REMOTE_USER_HOME}"

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | $SHELL

export HOME="${ROOT_HOME}"
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}"

# without restarting the shell, ghci location would not be resolved from the updated PATH
exec $SHELL

# Clean up
# Clean up
rm -rf /var/lib/apt/lists/*

echo "Done!"
echo "Done!"