Skip to content

Commit

Permalink
Merge pull request #74 from DaneWeber/haskell-for-non-root
Browse files Browse the repository at this point in the history
Haskell for non root
  • Loading branch information
danielbraun89 authored Nov 26, 2022
2 parents 0d45ba5 + 008c312 commit f16649d
Showing 1 changed file with 18 additions and 11 deletions.
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!"

0 comments on commit f16649d

Please sign in to comment.