Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dn-cmenu-overlay-1
Browse files Browse the repository at this point in the history
  • Loading branch information
dfordivam committed Sep 26, 2024
2 parents 6d48956 + e38c41b commit 00cf4a5
Show file tree
Hide file tree
Showing 67 changed files with 5,895 additions and 20,129 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,5 @@ jobs:
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$curDir = Get-Location
Write-Host "Current Working Directory: $curDir"
./scripts/bootstrap/bootstrap-haskell.ps1 -InstallDir ${GITHUB_WORKSPACE} -BootstrapUrl ("{0}/scripts/bootstrap/bootstrap-haskell" -f $curDir) -InBash -Msys2Env "MINGW64"
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/scripts/bootstrap/bootstrap-haskell.ps1 -UseBasicParsing))) -InstallDir ${GITHUB_WORKSPACE} -BootstrapUrl ("{0}/scripts/bootstrap/bootstrap-haskell" -f $curDir) -InBash -Msys2Env "MINGW64" } catch { Write-Error $_ }
shell: pwsh

40 changes: 26 additions & 14 deletions app/ghcup/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import qualified GHCup.GHC as GHC
import qualified GHCup.HLS as HLS
import GHCup.OptParse

import GHCup.Utils.Pager
import GHCup.Download
import GHCup.Errors
import GHCup.Platform
Expand All @@ -46,7 +47,7 @@ import Data.Functor
import Data.Versions (version)
import Data.Maybe
import GHC.IO.Encoding
import Haskus.Utils.Variant.Excepts
import Data.Variant.Excepts
import Language.Haskell.TH
import Language.Haskell.TH.Syntax ( Quasi(qAddDependentFile) )
import Options.Applicative hiding ( style )
Expand All @@ -55,6 +56,7 @@ import Prelude hiding ( appendFile )
import System.Environment
import System.Exit
import System.IO hiding ( appendFile )
import System.IO.Unsafe ( unsafeInterleaveIO )
import Text.PrettyPrint.HughesPJClass ( prettyShow )

import qualified Data.ByteString as B
Expand All @@ -65,20 +67,19 @@ import qualified GHCup.Types as Types



toSettings :: Options -> IO (Settings, KeyBindings, UserSettings)
toSettings options = do
noColor <- isJust <$> lookupEnv "NO_COLOR"
toSettings :: Bool -> Maybe FilePath -> Options -> IO (Settings, KeyBindings, UserSettings)
toSettings noColor pagerCmd options = do
userConf <- runE @'[ JSONError ] ghcupConfigFile >>= \case
VRight r -> pure r
VLeft (V (JSONDecodeError e)) -> do
B.hPut stderr ("Error decoding config file: " <> (E.encodeUtf8 . T.pack . show $ e))
pure defaultUserSettings
_ -> do
die "Unexpected error!"
pure $ (\(s', k) -> (s', k, userConf)) $ mergeConf options userConf noColor
pure $ (\(s', k) -> (s', k, userConf)) $ mergeConf options userConf
where
mergeConf :: Options -> UserSettings -> Bool -> (Settings, KeyBindings)
mergeConf Options{..} UserSettings{..} noColor =
mergeConf :: Options -> UserSettings -> (Settings, KeyBindings)
mergeConf Options{..} UserSettings{..} =
let cache = fromMaybe (fromMaybe (Types.cache defaultSettings) uCache) optCache
metaCache = fromMaybe (fromMaybe (Types.metaCache defaultSettings) uMetaCache) optMetaCache
metaMode = fromMaybe (fromMaybe (Types.metaMode defaultSettings) uMetaMode) optMetaMode
Expand All @@ -93,6 +94,9 @@ toSettings options = do
platformOverride = optPlatform <|> (uPlatformOverride <|> Types.platformOverride defaultSettings)
mirrors = fromMaybe (Types.mirrors defaultSettings) uMirrors
defGHCConfOptions = fromMaybe (Types.defGHCConfOptions defaultSettings) uDefGHCConfOptions
pager = case fromMaybe (fromMaybe (Types.pager defaultSettings) uPager) (flip PagerConfig Nothing <$> optPager) of
PagerConfig b Nothing -> PagerConfig b pagerCmd
x -> x
in (Settings {..}, keyBindings)
#if defined(INTERNAL_DOWNLOADER)
defaultDownloader = Internal
Expand Down Expand Up @@ -166,22 +170,30 @@ ENV variables:

Report bugs at <https://github.com/haskell/ghcup-hs/issues>|]

customExecParser
args <- getArgs
pagerCmd <- unsafeInterleaveIO getPager

let
parseArgsWith opts' = execParserPure
(prefs showHelpOnError)
(info (opts <**> helper <**> versionHelp <**> numericVersionHelp <**> planJson <**> listCommands)
(info (opts' <**> helper <**> versionHelp <**> numericVersionHelp <**> planJson <**> listCommands)
(footerDoc (Just $ text main_footer))
)
>>= \opt@Options {..} -> do
) args


handleParseResult' pagerCmd (argsHasHelp args) (parseArgsWith opts) >>= \case
opt@Options {..} -> do

dirs@Dirs{..} <- getAllDirs

-- create ~/.ghcup dir
ensureDirectories dirs

(settings, keybindings, userConf) <- toSettings opt
no_color <- isJust <$> lookupEnv "NO_COLOR"
(settings, keybindings, userConf) <- toSettings no_color pagerCmd opt

-- logger interpreter
logfile <- runReaderT initGHCupFileLogging dirs
no_color <- isJust <$> lookupEnv "NO_COLOR"
let loggerConfig = LoggerConfig
{ lcPrintDebug = verbose settings
, consoleOutter = T.hPutStr stderr
Expand Down Expand Up @@ -299,7 +311,7 @@ Report bugs at <https://github.com/haskell/ghcup-hs/issues>|]
Test testCommand -> test testCommand settings appState runLogger
Set setCommand -> set setCommand runAppState runLeanAppState runLogger
UnSet unsetCommand -> unset unsetCommand runLeanAppState runLogger
List lo -> list lo no_color runAppState
List lo -> list lo no_color (pager settings) runAppState
Rm rmCommand -> rm rmCommand runAppState runLogger
DInfo -> dinfo runAppState runLogger
Compile compileCommand -> compile compileCommand settings dirs runAppState runLogger
Expand Down
6 changes: 2 additions & 4 deletions cabal.ghc8107.Unix.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ constraints: any.Cabal ==3.10.3.0,
any.happy ==1.20.1.1,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.http-io-streams ==0.1.7.0,
Expand Down Expand Up @@ -235,4 +233,4 @@ constraints: any.Cabal ==3.10.3.0,
any.zlib ==0.6.3.0,
zlib -bundled-c-zlib -non-blocking-ffi -pkg-config,
any.zlib-bindings ==0.1.1.5
index-state: hackage.haskell.org 2024-06-07T21:16:52Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc8107.Win32.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ constraints: any.Cabal ==3.10.2.1 || ==3.10.3.0,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskell-lexer ==1.1.1,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.hspec ==2.10.10,
Expand Down Expand Up @@ -234,4 +232,4 @@ constraints: any.Cabal ==3.10.2.1 || ==3.10.3.0,
yaml +no-examples +no-exe,
any.zlib ==0.6.3.0,
zlib +bundled-c-zlib -non-blocking-ffi -pkg-config
index-state: hackage.haskell.org 2024-04-15T02:49:22Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc902.Unix.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ constraints: any.Cabal ==3.10.3.0,
any.happy ==1.20.1.1,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.http-io-streams ==0.1.7.0,
Expand Down Expand Up @@ -242,4 +240,4 @@ constraints: any.Cabal ==3.10.3.0,
any.zlib-bindings ==0.1.1.5,
any.zstd ==0.1.3.0,
zstd +standalone
index-state: hackage.haskell.org 2024-06-07T21:16:52Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc902.Win32.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ constraints: any.Cabal ==3.10.3.0,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskell-lexer ==1.1.1,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.hspec ==2.10.10,
Expand Down Expand Up @@ -244,4 +242,4 @@ constraints: any.Cabal ==3.10.3.0,
zlib +bundled-c-zlib -non-blocking-ffi -pkg-config,
any.zstd ==0.1.3.0,
zstd +standalone
index-state: hackage.haskell.org 2024-04-15T02:49:22Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc928.Unix.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ constraints: any.Cabal ==3.10.3.0,
any.happy ==1.20.1.1,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.http-io-streams ==0.1.7.0,
Expand Down Expand Up @@ -243,4 +241,4 @@ constraints: any.Cabal ==3.10.3.0,
any.zlib-bindings ==0.1.1.5,
any.zstd ==0.1.3.0,
zstd +standalone
index-state: hackage.haskell.org 2024-06-07T21:16:52Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc928.Win32.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ constraints: any.Cabal ==3.10.3.0,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskell-lexer ==1.1.1,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.hspec ==2.10.10,
Expand Down Expand Up @@ -245,4 +243,4 @@ constraints: any.Cabal ==3.10.3.0,
zlib +bundled-c-zlib -non-blocking-ffi -pkg-config,
any.zstd ==0.1.3.0,
zstd +standalone
index-state: hackage.haskell.org 2024-04-15T02:49:22Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc948.Unix.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ constraints: any.Cabal ==3.10.3.0,
any.happy ==1.20.1.1,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.http-io-streams ==0.1.7.0,
Expand Down Expand Up @@ -241,4 +239,4 @@ constraints: any.Cabal ==3.10.3.0,
any.zlib-bindings ==0.1.1.5,
any.zstd ==0.1.3.0,
zstd +standalone
index-state: hackage.haskell.org 2024-06-07T21:16:52Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
6 changes: 2 additions & 4 deletions cabal.ghc948.Win32.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ constraints: any.Cabal ==3.10.3.0,
any.hashable ==1.4.4.0,
hashable +integer-gmp -random-initial-seed,
any.haskell-lexer ==1.1.1,
any.haskus-utils-data ==1.4,
any.haskus-utils-types ==1.5.1,
any.haskus-utils-variant ==3.3,
any.variant == 1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.hspec ==2.10.10,
Expand Down Expand Up @@ -243,4 +241,4 @@ constraints: any.Cabal ==3.10.3.0,
zlib +bundled-c-zlib -non-blocking-ffi -pkg-config,
any.zstd ==0.1.3.0,
zstd +standalone
index-state: hackage.haskell.org 2024-04-15T02:49:22Z
index-state: hackage.haskell.org 2024-08-17T15:10:55Z
12 changes: 12 additions & 0 deletions data/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,15 @@ mirrors:
def-ghc-conf-options:
- "--enable-ld-override"

# Use a pager for e.g. 'ghcup list' output. 'cmd' is optional (if omitted
# will try to discover pager via GHCUP_PAGER/PAGER env vars or a predefined set of executables).
#
# You can also set only a boolean value:
# pager: true
#
# Or only a cmd (implies 'true' for all boolean values):
# pager: "less -R"
pager:
list: true # enabled for list action
cmd: "less -R" # the command

2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ You don't need to. However, some users seem to prefer to have a central tool tha
at the same time. Additionally, it can allow better sharing of GHC installation across these tools.
Also see:

* https://docs.haskellstack.org/en/stable/yaml_configuration/#system-ghc
* https://docs.haskellstack.org/en/stable/configure/yaml/non-project/#system-ghc
* https://github.com/commercialhaskell/stack/pull/5585

### Why does ghcup not use stack code?
Expand Down
33 changes: 28 additions & 5 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ Other tags include:
For man pages to work you need [man-db](http://man-db.nongnu.org/) as your `man` provider, then issue `man ghc`. Manpages only work for the currently set ghc.
`MANPATH` may be required to be unset.

## Pager

You can have `ghcup list` use a pager, similar to git. E.g. run:

```sh
ghcup --paginate list
```

To set a specific pager you can use either `GHCUP_PAGER` or `PAGER` environment variable.

To make the changes permanent, you can add the following to your config:

```yaml
pager: most
```
Refer to the [config.yaml](https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml) template for more fine-grained
control.
## Shell-completion
Shell completions are in [scripts/shell-completions](https://github.com/haskell/ghcup-hs/tree/master/scripts/shell-completions) directory of this repository.
Expand Down Expand Up @@ -245,7 +264,8 @@ GHC versions there are two strategies.

### Strategy 1: Stack hooks (new, recommended)

Since stack 2.9.1 you can customize the installation logic of GHC completely, see [https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation](https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation).
Since stack 2.9.1 you can customize the installation logic of GHC completely, see
[https://docs.haskellstack.org/en/stable/configure/customisation_scripts/#ghc-installation-customisation](https://docs.haskellstack.org/en/stable/configure/customisation_scripts/#ghc-installation-customisation).

We can use this to simply invoke ghcup whenever stack is trying to install/discover a GHC versions. This
is done via placing a shell script at `~/.stack/hooks/ghc-install.sh` and making it executable.
Expand Down Expand Up @@ -297,7 +317,9 @@ url-source:
- StackSetupURL
```

You can customize or add sections to the setup-info similar to how the [stack documentation](https://docs.haskellstack.org/en/stable/yaml_configuration/#setup-info) explains it. E.g. to change the 9.4.7 bindist, you might do:
You can customize or add sections to the setup-info similar to how the
[stack documentation](https://docs.haskellstack.org/en/stable/configure/yaml/non-project/#setup-info)
explains it. E.g. to change the 9.4.7 bindist, you might do:

```yaml
url-source:
Expand Down Expand Up @@ -341,7 +363,8 @@ extra-include-dirs:
- C:\ghcup\msys64\mingw64\include
```

Also check out: [https://docs.haskellstack.org/en/stable/yaml_configuration](https://docs.haskellstack.org/en/stable/yaml_configuration)
Also check out:
[https://docs.haskellstack.org/en/stable/configure/yaml/non-project](https://docs.haskellstack.org/en/stable/configure/yaml/non-project)

## Mirrors (proper)

Expand Down Expand Up @@ -660,7 +683,7 @@ non-interactively, as below. The parameters to the PowerShell script are
specified positionally, after `-ArgumentList`:

```ps
$ErrorActionPreference = 'Stop';Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false,$true,$true,$false,$false,$false,$false,"C:\" } catch { Write-Error $_ }
$ErrorActionPreference = 'Stop';Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Minimal -InBash -InstallDir "C:\" } catch { Write-Error $_ }
```

`$ErrorActionPreference = 'Stop'` here acts like `set -e` and stops execution if ghcup installation fails.
Expand Down Expand Up @@ -810,7 +833,7 @@ manually added and trusted.

On Windows, you can disable the use of `curl` like so:
~~~pwsh
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true,$false,$false,$false,$false,$false,$false,"","","","",$true } catch { Write-Error $_ }
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl } catch { Write-Error $_ }
~~~

In some circumstances, an organisation may install their own CA certificates
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ hide:

<div class="command-button">
<pre>
<span class="ghcup-command" id="ghcup-command-windows">Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true } catch { Write-Error $_ }
<span class="ghcup-command" id="ghcup-command-windows">Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl } catch { Write-Error $_ }
</span>
</pre>
<button class="btn" onclick="copyToClipboardWin()" id="ghcup-windows-button"><i class="fa fa-copy"></i></button>
Expand Down
Loading

0 comments on commit 00cf4a5

Please sign in to comment.