-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support stacks installation strategy and metadata, wrt #892 #907
Conversation
hasufell
commented
Oct 22, 2023
•
edited
Loading
edited
{-# LANGUAGE RecordWildCards #-} | ||
|
||
{-| | ||
Module : GHCup.Types.Stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bold copy pasta, but uses a different Version
type.
@@ -36,6 +36,9 @@ import Data.Void (Void) | |||
ghcupURL :: URI | |||
ghcupURL = [uri|https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.8.yaml|] | |||
|
|||
stackSetupURL :: URI | |||
stackSetupURL = [uri|https://raw.githubusercontent.com/commercialhaskell/stackage-content/master/stack/stack-setup-2.yaml|] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stack setup URL
TODO:
- allow users to overwrite setup info sections like in stack
Settings{ stackSetupSource, stackSetup } <- lift getSettings | ||
dlinfo <- if stackSetup | ||
then do | ||
lift $ logInfo "Using stack's setup-info to install GHC" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entry point for stacks GHC install logic
lib/GHCup/Download.hs
Outdated
getStackDownloadInfo stackSetupSource keys@(_:_) GHC tv@(GHCTargetVersion Nothing v) = | ||
case stackSetupSource of | ||
StackSetupURL -> do | ||
(dli :: Stack.SetupInfo) <- liftE $ reThrowAll @_ @_ @'[DownloadFailed] DownloadFailed $ getBase stackSetupURL | ||
let siGHCs = Stack.siGHCs $ dli | ||
ghcVersionsPerKey = (\key -> M.lookup key siGHCs) <$> (T.pack <$> keys) | ||
ghcVersions <- (listToMaybe . catMaybes $ ghcVersionsPerKey) ?? (NoDownload tv GHC Nothing) | ||
ghcVersion <- M.lookup v ghcVersions ?? (NoDownload tv GHC Nothing) | ||
fromStackDownloadInfo (Stack.gdiDownloadInfo ghcVersion) | ||
where | ||
fromStackDownloadInfo :: MonadThrow m => Stack.DownloadInfo -> m DownloadInfo | ||
fromStackDownloadInfo Stack.DownloadInfo{..} = do | ||
url <- either (\e -> throwM $ ParseError (show e)) pure $ parseURI strictURIParserOptions . E.encodeUtf8 $ downloadInfoUrl | ||
sha256 <- maybe (throwM $ DigestMissing url) (pure . E.decodeUtf8) downloadInfoSha256 | ||
pure $ DownloadInfo url (Just $ RegexDir "ghc-.*") sha256 Nothing Nothing | ||
getStackDownloadInfo _ _ t v = throwE $ NoDownload v t Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the meat. Here we download the stacks setup info, index via the OS/platform keys, descend into version and then turn it into GHCup internal DownloadInfo
type to let the rest of the callstack do the rest.
lib/GHCup/Download.hs
Outdated
(dli :: Stack.SetupInfo) <- liftE $ reThrowAll @_ @_ @'[DownloadFailed] DownloadFailed $ getBase stackSetupURL | ||
let siGHCs = Stack.siGHCs $ dli | ||
ghcVersionsPerKey = (\key -> M.lookup key siGHCs) <$> (T.pack <$> keys) | ||
ghcVersions <- (listToMaybe . catMaybes $ ghcVersionsPerKey) ?? (NoDownload tv GHC Nothing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we pick the first key that has a valid version. We don't attempt multiple downloads.
019a6dd
to
fe888be
Compare