Compare commits

..

1 Commits

Author SHA1 Message Date
3f968cb1c0 WIP 2022-09-22 00:03:26 +08:00
4 changed files with 32 additions and 70 deletions

View File

@@ -360,13 +360,18 @@ deriving instance Show InstallSetError
-- | A build failed. -- | A build failed.
data BuildFailed = forall es . (ToVariantMaybe BuildFailed es, PopVariant BuildFailed es, Pretty (V es), Show (V es)) => BuildFailed FilePath (V es) data BuildFailed = forall es . (ToVariantMaybe BuildFailed es, PopVariant BuildFailed es, Pretty (V es), Show (V es)) => BuildFailed FilePath (V es) (Just Requirements)
instance Pretty BuildFailed where instance Pretty BuildFailed where
pPrint (BuildFailed path reason) = pPrint (BuildFailed path reason req) =
case reason of case reason of
VMaybe (_ :: BuildFailed) -> pPrint reason VMaybe (_ :: BuildFailed) -> pPrint reason
_ -> text "BuildFailed failed in dir" <+> text (path <> ":") <+> pPrint reason _ -> text "BuildFailed failed in dir" <+> text (path <> ":") <+> pPrint reason
<+> printToolReq'
where
printToolReq' = case req of
Nothing -> T.pack ""
Just req' -> prettyRequirementsError req'
deriving instance Show BuildFailed deriving instance Show BuildFailed

View File

@@ -68,6 +68,17 @@ prettyRequirements Requirements {..} =
n = if not . T.null $ _notes then "\n Note: " <> _notes else "" n = if not . T.null $ _notes then "\n Note: " <> _notes else ""
in "System requirements " <> d <> n in "System requirements " <> d <> n
prettyRequirementsError :: Requirements -> T.Text
prettyRequirementsError Requirements {..} =
let d = if not . null $ _distroPKGs
then "\nMake sure the following distro packages "
<> "are installed: "
<> T.intercalate " " _distroPKGs
else ""
n = if not . T.null $ _notes then "\nMake sure the following requirements are met: " <> _notes else ""
in d <> n
rawRequirements :: Requirements -> T.Text rawRequirements :: Requirements -> T.Text
rawRequirements Requirements {..} = rawRequirements Requirements {..} =
if not . null $ _distroPKGs if not . null $ _distroPKGs

View File

@@ -12,8 +12,7 @@
# * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation # * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation
# * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install # * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install
# * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install # * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install
# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK - disable installation of stack # * BOOTSTRAP_HASKELL_INSTALL_STACK - whether to install latest stack
# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK - disable installation stack ghcup hook
# * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls # * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls
# * BOOTSTRAP_HASKELL_ADJUST_BASHRC - whether to adjust PATH in bashrc (prepend) # * 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 # * BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG - whether to adjust mingw paths in cabal.config on windows
@@ -693,44 +692,40 @@ ask_hls() {
} }
ask_stack() { ask_stack() {
if [ -n "${BOOTSTRAP_HASKELL_INSTALL_NO_STACK}" ] ; then if [ -n "${BOOTSTRAP_HASKELL_INSTALL_STACK}" ] ; then
return 0
elif [ -n "${BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK}" ] ; then
return 1 return 1
fi fi
if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
echo "-------------------------------------------------------------------------------" echo "-------------------------------------------------------------------------------"
warn "Do you want to enable better integration of stack with GHCup?" warn "Do you want to install stack?"
warn "This means that stack won't install its own GHC versions, but uses GHCup's." warn "Stack is a haskell build tool similar to cabal that is used by some projects."
warn "For more information see:" warn "Also see https://docs.haskellstack.org/"
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 ""
warn "[Y] Yes [N] No [?] Help (default is \"Y\")." warn "[Y] Yes [N] No [?] Help (default is \"N\")."
warn "" warn ""
while true; do while true; do
read -r stack_answer </dev/tty read -r stack_answer </dev/tty
case $stack_answer in case $stack_answer in
[Yy]* | "") [Yy]*)
return 2 ;;
[Nn]*)
return 1 ;; return 1 ;;
[Nn]* | "")
return 0 ;;
*) *)
echo "Possible choices are:" echo "Possible choices are:"
echo echo
echo "Y - Yes, enable better integration (default)" echo "Y - Yes, install stack"
echo "N - No, keep stacks vanilla behavior" echo "N - No, don't install anything more (default)"
echo echo
echo "Please make your choice and press ENTER." echo "Please make your choice and press ENTER."
;; ;;
esac esac
done done
else else
return 2 return 0
fi fi
unset stack_answer unset stack_answer
@@ -747,7 +742,7 @@ echo "This script can download and install the following binaries:"
echo " * ghcup - The Haskell toolchain installer" echo " * ghcup - The Haskell toolchain installer"
echo " * ghc - The Glasgow Haskell Compiler" echo " * ghc - The Glasgow Haskell Compiler"
echo " * cabal - The Cabal build tool for managing Haskell software" echo " * cabal - The Cabal build tool for managing Haskell software"
echo " * stack - A cross-platform program for developing Haskell projects (similar to cabal)" echo " * stack - (optional) A cross-platform program for developing Haskell projects"
echo " * hls - (optional) A language server for developers to integrate with their editor/IDE" echo " * hls - (optional) A language server for developers to integrate with their editor/IDE"
echo echo
if [ -z "${GHCUP_USE_XDG_DIRS}" ] ; then if [ -z "${GHCUP_USE_XDG_DIRS}" ] ; then
@@ -844,35 +839,7 @@ esac
case $ask_stack_answer in case $ask_stack_answer in
1) 1)
_eghcup --cache install stack || die "Stack installation failed" _eghcup --cache install stack || warn "Stack installation failed, continuing anyway"
;;
2)
_eghcup --cache install stack || die "Stack installation failed"
edo mkdir -p "${STACK_ROOOT:-$HOME/.stack}"/hooks
hook_exe="${STACK_ROOOT:-$HOME/.stack}"/hooks/ghc-install.sh
hook_url="https://www.haskell.org/ghcup/sh/hooks/stack/ghc-install.sh"
if [ -e "${hook_exe}" ] ; then
warn "$hook_exe already exists, skipping hook installation."
warn "If you want to reinstall the hook, delete it manually and re-run"
warn "this script!"
else
case "${BOOTSTRAP_HASKELL_DOWNLOADER}" in
"curl")
# shellcheck disable=SC2086
edo curl -Lf ${GHCUP_CURL_OPTS} "${hook_url}" > "${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 esac

View File

@@ -1,21 +0,0 @@
#!/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