diff --git a/app/ghcup/BrickMain.hs b/app/ghcup/BrickMain.hs index 7143f525..66c851af 100644 --- a/app/ghcup/BrickMain.hs +++ b/app/ghcup/BrickMain.hs @@ -5,6 +5,8 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ViewPatterns #-} +{-# OPTIONS_GHC -Wno-unused-record-wildcards #-} +{-# OPTIONS_GHC -Wno-unused-matches #-} module BrickMain where @@ -16,7 +18,6 @@ import GHCup.Types hiding ( LeanAppState(..) ) import GHCup.Utils import GHCup.OptParse.Common (logGHCPostRm) import GHCup.Prelude ( decUTF8Safe ) -import GHCup.Prelude.File import GHCup.Prelude.Logger import GHCup.Prelude.Process import GHCup.Prompts @@ -49,7 +50,6 @@ import Data.Vector ( Vector import Data.Versions import Haskus.Utils.Variant.Excepts import Prelude hiding ( appendFile ) -import System.FilePath import System.Exit import System.IO.Unsafe import Text.PrettyPrint.HughesPJClass ( prettyShow ) @@ -61,8 +61,33 @@ import qualified Data.Text.Lazy as L import qualified Graphics.Vty as Vty import qualified Data.Vector as V import System.Environment (getExecutablePath) +#if !IS_WINDOWS +import GHCup.Prelude.File +import System.FilePath import qualified System.Posix.Process as SPP +#endif + +installedSign :: String +#if IS_WINDOWS +installedSign = "I " +#else +installedSign = "✓ " +#endif + +setSign :: String +#if IS_WINDOWS +setSign = "IS" +#else +setSign = "✔✔" +#endif + +notInstalledSign :: String +#if IS_WINDOWS +notInstalledSign = "X " +#else +notInstalledSign = "✗ " +#endif hiddenTools :: [Tool] hiddenTools = [] @@ -165,9 +190,9 @@ ui dimAttrs BrickState{ appSettings = as@BrickSettings{}, ..} in withDefAttr listAttr . drawListElements (renderItem minTagSize minVerSize) True $ bis renderItem minTagSize minVerSize _ b listResult@ListResult{lTag = lTag', ..} = let marks = if - | lSet -> (withAttr (attrName "set") $ str "✔✔") - | lInstalled -> (withAttr (attrName "installed") $ str "✓ ") - | otherwise -> (withAttr (attrName "not-installed") $ str "✗ ") + | lSet -> (withAttr (attrName "set") $ str setSign) + | lInstalled -> (withAttr (attrName "installed") $ str installedSign) + | otherwise -> (withAttr (attrName "not-installed") $ str notInstalledSign) ver = case lCross of Nothing -> T.unpack . prettyVer $ lVer Just c -> T.unpack (c <> "-" <> prettyVer lVer) @@ -500,12 +525,15 @@ install' _ (_, ListResult {..}) = do forM_ (_viPostInstall =<< vi) $ \msg -> logInfo msg case lTool of GHCup -> do +#if !IS_WINDOWS up <- liftIO $ fmap (either (const Nothing) Just) $ try @_ @SomeException $ canonicalizePath (binDir "ghcup" <.> exeExt) when ((normalise <$> up) == Just (normalise ce)) $ -- TODO: track cli arguments of previous invocation liftIO $ SPP.executeFile ce False ["tui"] Nothing +#else logInfo "Please restart 'ghcup' for the changes to take effect" +#endif _ -> pure () pure $ Right () VRight (vi, _, _) -> do diff --git a/cabal.project.release b/cabal.project.release index c8c11c45..67f00ccc 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -4,35 +4,26 @@ optional-packages: ./vendored/*/*.cabal optimization: 2 -source-repository-package - type: git - location: https://github.com/fosskers/versions.git - tag: 7bc3355348aac3510771d4622aff09ac38c9924d +package ghcup + flags: +tui if os(linux) - package ghcup - flags: +tui if arch(x86_64) || arch(i386) package * ghc-options: -split-sections -optl-static elif os(darwin) constraints: zlib +bundled-c-zlib, lzma +static - package ghcup - flags: +tui elif os(mingw32) constraints: zlib +bundled-c-zlib, lzma +static, - text -simdutf - package ghcup - flags: -tui + text -simdutf, + vty-windows >=0.1.0.3 elif os(freebsd) constraints: zlib +bundled-c-zlib, zip +disable-zstd package * ghc-options: -split-sections -pgmc clang++14 - package ghcup - flags: +tui constraints: http-io-streams -brotli, any.aeson >= 2.0.1.0, diff --git a/ghcup.cabal b/ghcup.cabal index e97d9bbd..3b0ff9b9 100644 --- a/ghcup.cabal +++ b/ghcup.cabal @@ -36,7 +36,7 @@ source-repository head flag tui description: - Build the brick powered tui (ghcup tui). This is disabled on windows. + Build the brick powered tui (ghcup tui). default: False manual: True @@ -86,7 +86,7 @@ common app-common-depends , unordered-containers ^>=0.2 , uri-bytestring ^>=0.3.2.2 , utf8-string ^>=1.0 - , vector ^>=0.12 + , vector >=0.12 && <0.14 , versions >=6.0.3 && <6.1 , yaml-streamly ^>=0.12.0 @@ -190,7 +190,7 @@ library , unliftio-core ^>=0.2.0.1 , unordered-containers ^>=0.2.10.0 , uri-bytestring ^>=0.3.2.2 - , vector ^>=0.12 + , vector >=0.12 && <0.14 , versions >=6.0.3 && <6.1 , word8 ^>=0.1.3 , yaml-streamly ^>=0.12.0 @@ -236,9 +236,9 @@ library , unix ^>=2.7 , unix-bytestring ^>=0.3.7.3 - if (flag(tui) && !os(windows)) + if flag(tui) cpp-options: -DBRICK - build-depends: vty ^>=5.39 + build-depends: vty ^>=6.0 library ghcup-optparse import: app-common-depends @@ -284,7 +284,7 @@ library ghcup-optparse if flag(internal-downloader) cpp-options: -DINTERNAL_DOWNLOADER - if (flag(tui) && !os(windows)) + if flag(tui) cpp-options: -DBRICK if os(windows) @@ -320,14 +320,13 @@ executable ghcup if flag(internal-downloader) cpp-options: -DINTERNAL_DOWNLOADER - if (flag(tui) && !os(windows)) + if flag(tui) cpp-options: -DBRICK other-modules: BrickMain build-depends: - , brick ^>=1.5 + , brick ^>=2.1 , transformers ^>=0.5 - , unix ^>=2.7 - , vty ^>=5.39 + , vty ^>=6.0 if os(windows) cpp-options: -DIS_WINDOWS diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index 974a9ab4..53b3c3ce 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -475,7 +475,7 @@ data KeyBindings = KeyBindings deriving (Show, GHC.Generic) instance NFData KeyBindings -#if defined(IS_WINDOWS) || !defined(BRICK) +#if !defined(BRICK) instance NFData Key instance NFData Modifier diff --git a/scripts/bootstrap/bootstrap-haskell b/scripts/bootstrap/bootstrap-haskell index b693cb3b..0098eb5f 100755 --- a/scripts/bootstrap/bootstrap-haskell +++ b/scripts/bootstrap/bootstrap-haskell @@ -172,9 +172,8 @@ _done() { green "Start a new haskell project in the current directory via:" green " cabal init --interactive" green - green "Install other GHC versions and tools via:" - green " ghcup list" - green " ghcup install " + green "To install other GHC versions and tools, run:" + green " ghcup tui" green green "To install system libraries and update msys2/mingw64," green "open the \"Mingw haskell shell\""