diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index 9caec8b..25ed299 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -12,7 +12,8 @@ # * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation # * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install # * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install -# * BOOTSTRAP_HASKELL_INSTALL_STACK - whether to install latest stack +# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK - disable installation of stack +# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK - disable installation stack ghcup hook # * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls # * BOOTSTRAP_HASKELL_ADJUST_BASHRC - whether to adjust PATH in bashrc (prepend) # * BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG - whether to adjust mingw paths in cabal.config on windows @@ -692,40 +693,44 @@ ask_hls() { } ask_stack() { - if [ -n "${BOOTSTRAP_HASKELL_INSTALL_STACK}" ] ; then + if [ -n "${BOOTSTRAP_HASKELL_INSTALL_NO_STACK}" ] ; then + return 0 + elif [ -n "${BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK}" ] ; then return 1 fi if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then echo "-------------------------------------------------------------------------------" - warn "Do you want to install stack?" - warn "Stack is a haskell build tool similar to cabal that is used by some projects." - warn "Also see https://docs.haskellstack.org/" + warn "Do you want to enable better integration of stack with GHCup?" + warn "This means that stack won't install its own GHC versions, but uses GHCup's." + warn "For more information see:" + warn " https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental" + warn "If you want to keep stacks vanilla behavior, answer 'No'." warn "" - warn "[Y] Yes [N] No [?] Help (default is \"N\")." + warn "[Y] Yes [N] No [?] Help (default is \"Y\")." warn "" while true; do read -r stack_answer "${hook_exe}" + ;; + "wget") + # shellcheck disable=SC2086 + edo wget -O /dev/stdout ${GHCUP_WGET_OPTS} "${hook_url}" > "${hook_exe}" + ;; + *) + die "Unknown downloader: ${BOOTSTRAP_HASKELL_DOWNLOADER}" + ;; + esac + edo chmod +x "${hook_exe}" + fi + ;; *) ;; esac diff --git a/scripts/hooks/stack/ghc-install.sh b/scripts/hooks/stack/ghc-install.sh new file mode 100644 index 0000000..01d20ff --- /dev/null +++ b/scripts/hooks/stack/ghc-install.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# see https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental +# for documentation about hooks + +set -euo pipefail + +case $HOOK_GHC_TYPE in + bindist) + echo "$(ghcup run --ghc "$HOOK_GHC_VERSION" --install)/ghc" + ;; + git) + # TODO: should be somewhat possible + >&2 echo "Hook doesn't support installing from source" + exit 1 + ;; + *) + >&2 echo "Unsupported GHC installation type: $HOOK_GHC_TYPE" + exit 2 + ;; +esac