Skip to content

Commit

Permalink
Only use ghcup where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
chreekat authored and Mikolaj committed Apr 16, 2024
1 parent 3792f65 commit 6b6c684
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
38 changes: 7 additions & 31 deletions .gitlab/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,26 @@ set -Eeuo pipefail

source "$CI_PROJECT_DIR/.gitlab/common.sh"

export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"
if [[ "$(uname)" == "Linux" ]]; then
export PATH="/opt/ghc/${GHC_VERSION}/bin:${PATH}"
# Not all runners use ci-images, so ghcup is used.
else
. "$CI_PROJECT_DIR/.gitlab/ghcup.sh"
fi

export CABAL_DIR="$CI_PROJECT_DIR/cabal"

case "$(uname)" in
MSYS_*|MINGW*)
export CABAL_DIR="$(cygpath -w "$CABAL_DIR")"
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
EXE_EXT=".exe"
;;
*)
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
EXE_EXT=""
;;
esac

mkdir -p "$CABAL_DIR"
mkdir -p "$GHCUP_BINDIR"
export PATH="$GHCUP_BINDIR:$PATH"

export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
export BOOTSTRAP_HASKELL_GHC_VERSION=$GHC_VERSION
export BOOTSTRAP_HASKELL_CABAL_VERSION=$CABAL_INSTALL_VERSION
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
# We don't use stack, and it isn't available on i386-deb9
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes

# for some reason the subshell doesn't pick up the arm64 environment on darwin
# and starts installing x86_64 GHC
case "$(uname -s)" in
"Darwin"|"darwin")
case "$(/usr/bin/arch)" in
aarch64|arm64|armv8l)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac

# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
# and
Expand Down Expand Up @@ -74,7 +51,6 @@ case "$(uname)" in
esac

args=(
-w "ghc-$GHC_VERSION"
--disable-profiling
--enable-executable-stripping
--project-file=cabal.project.release
Expand Down
38 changes: 38 additions & 0 deletions .gitlab/ghcup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"

case "$(uname)" in
MSYS_*|MINGW*)
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
;;
*)
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
;;
esac

mkdir -p "$GHCUP_BINDIR"
export PATH="$GHCUP_BINDIR:$PATH"

export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
export BOOTSTRAP_HASKELL_GHC_VERSION=$GHC_VERSION
export BOOTSTRAP_HASKELL_CABAL_VERSION=$CABAL_INSTALL_VERSION
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
# We don't use stack, and it isn't available on i386-deb9
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes

# for some reason the subshell doesn't pick up the arm64 environment on darwin
# and starts installing x86_64 GHC
case "$(uname -s)" in
"Darwin"|"darwin")
case "$(/usr/bin/arch)" in
aarch64|arm64|armv8l)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac

0 comments on commit 6b6c684

Please sign in to comment.