Skip to content

Commit

Permalink
Add global-hints-location option
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Mar 28, 2024
1 parent c55283b commit 1f99734
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Other enhancements:
versions before 9.4.
* Add flag `--[no-]save-hackage-creds` to Stack's `upload` command, which takes
precedence over the existing `save-hackage-creds` configuration option.
* In YAML configuration files, the `global-hints-location` key is introduced to
allow the location of the global hints YAML specification file to be
specified.

Bug fixes:

Expand Down
31 changes: 31 additions & 0 deletions doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,37 @@ See [`setup-info`](#setup-info).

This option is incompatible with `system-ghc: true`.

### global-hints-location

:octicons-tag-24: UNRELEASED

Default:

~~~yaml
global-hints-location:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-content/master/stack/global-hints.yaml
~~~

(as set in the `pantry` library)

Sets the location of the global hints YAML file. The location can be either a
filepath of a local file or a URL. The filepath can be absolute or relative to
the Stack root.

For example:

~~~yaml
global-hints-location:
filepath: \pantry\global-hints.yaml
~~~

or:

~~~yaml
global-hints-location:
url: https://example.com/global-hints/location/global-hints.yaml
~~~

### hackage-base-url

[:octicons-tag-24: 1.9.1](https://github.com/commercialhaskell/stack/releases/tag/v1.9.1)
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ dependencies:
- neat-interpolation
- open-browser
- optparse-applicative >= 0.18.1.0
- pantry >= 0.9.3.2
- pantry >= 0.10.0
- path >= 0.9.5
- path-io
# In order for Cabal (the tool) to build Stack, it needs to be told of the
Expand Down
7 changes: 7 additions & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ configFromConfigMonoid
<> "/" <> display day <> ".yaml"
mkRSLUrl builder = RSLUrl (utf8BuilderToText builder) Nothing
addr' = display $ T.dropWhileEnd (=='/') addr
globalHintsLoc <- case getFirst configMonoid.globalHintsLocation of
Nothing -> pure defaultGlobalHintsLocation
Just unresolverGlobalHintsLoc -> do
resolvedGlobalHintsLocation <-
resolvePaths (Just stackRoot) unresolverGlobalHintsLoc
pure $ const resolvedGlobalHintsLocation
let stackDeveloperMode = fromFirst
stackDeveloperModeDefault
configMonoid.stackDeveloperMode
Expand Down Expand Up @@ -557,6 +563,7 @@ configFromConfigMonoid
clConnectionCount
casa
snapLoc
globalHintsLoc
(\pantryConfig -> initUserStorage
(stackRoot </> relFileStorage)
( \userStorage -> inner Config
Expand Down
8 changes: 8 additions & 0 deletions src/Stack/Types/ConfigMonoid.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ data ConfigMonoid = ConfigMonoid
-- ^ Casa repository prefix (deprecated).
, snapshotLocation :: !(First Text)
-- ^ Custom location of LTS/Nightly snapshots
, globalHintsLocation :: !(First (Unresolved GlobalHintsLocation))
-- ^ Custom location of global hints
, noRunCompile :: !FirstFalse
-- ^ See: 'configNoRunCompile'
, stackDeveloperMode :: !(First Bool)
Expand Down Expand Up @@ -336,6 +338,8 @@ parseConfigMonoidObject rootDir obj = do
casaOpts <- jsonSubWarnings (obj ..:? configMonoidCasaOptsName ..!= mempty)
casaRepoPrefix <- First <$> obj ..:? configMonoidCasaRepoPrefixName
snapshotLocation <- First <$> obj ..:? configMonoidSnapshotLocationName
globalHintsLocation <-
First <$> jsonSubWarningsT (obj ..:? configMonoidGlobalHintsLocationName)
noRunCompile <- FirstFalse <$> obj ..:? configMonoidNoRunCompileName
stackDeveloperMode <- First <$> obj ..:? configMonoidStackDeveloperModeName
pure ConfigMonoid
Expand Down Expand Up @@ -402,6 +406,7 @@ parseConfigMonoidObject rootDir obj = do
, casaOpts
, casaRepoPrefix
, snapshotLocation
, globalHintsLocation
, noRunCompile
, stackDeveloperMode
}
Expand Down Expand Up @@ -596,6 +601,9 @@ configMonoidCasaRepoPrefixName = "casa-repo-prefix"
configMonoidSnapshotLocationName :: Text
configMonoidSnapshotLocationName = "snapshot-location-base"

configMonoidGlobalHintsLocationName :: Text
configMonoidGlobalHintsLocationName = "global-hints-location"

configMonoidNoRunCompileName :: Text
configMonoidNoRunCompileName = "script-no-run-compile"

Expand Down
8 changes: 4 additions & 4 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ library
, neat-interpolation
, open-browser
, optparse-applicative >=0.18.1.0
, pantry >=0.9.3.2
, pantry >=0.10.0
, path >=0.9.5
, path-io
, persistent >=2.14.0.0 && <2.15
Expand Down Expand Up @@ -517,7 +517,7 @@ executable stack
, neat-interpolation
, open-browser
, optparse-applicative >=0.18.1.0
, pantry >=0.9.3.2
, pantry >=0.10.0
, path >=0.9.5
, path-io
, persistent >=2.14.0.0 && <2.15
Expand Down Expand Up @@ -620,7 +620,7 @@ executable stack-integration-test
, open-browser
, optparse-applicative >=0.18.1.0
, optparse-generic
, pantry >=0.9.3.2
, pantry >=0.10.0
, path >=0.9.5
, path-io
, persistent >=2.14.0.0 && <2.15
Expand Down Expand Up @@ -736,7 +736,7 @@ test-suite stack-unit-test
, neat-interpolation
, open-browser
, optparse-applicative >=0.18.1.0
, pantry >=0.9.3.2
, pantry >=0.10.0
, path >=0.9.5
, path-io
, persistent >=2.14.0.0 && <2.15
Expand Down
5 changes: 4 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
snapshot: lts-22.7 # GHC 9.6.4

packages:
- .

extra-deps:
# Cabal is pruned because process is a GHC boot package, and has to be specified
# again.
- Cabal-3.10.1.0@sha256:6d11adf7847d9734e7b02785ff831b5a0d11536bfbcefd6634b2b08411c63c94,12316
- pantry-0.9.3.2@sha256:336373d8cbb10505ff16ac6e35cb9d8a7f45293a908de1c00f55c133ee7dde86,7511
- pantry-0.10.0@sha256:6f99ee8d7cfeeb0e2513638618acf80c72d018e7f10120048fa120a409b9dcd2,7864
# GHC 9.6.4 comes with process-1.6.17.0, which can segfault on macOS.
- process-1.6.18.0@sha256:cd0a3e0376b5a8525983d3131a31e52f9ffefc278ce635eec45a9d3987b8be3e,3025

Expand Down
6 changes: 3 additions & 3 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ packages:
original:
hackage: Cabal-3.10.1.0@sha256:6d11adf7847d9734e7b02785ff831b5a0d11536bfbcefd6634b2b08411c63c94,12316
- completed:
hackage: pantry-0.9.3.2@sha256:336373d8cbb10505ff16ac6e35cb9d8a7f45293a908de1c00f55c133ee7dde86,7511
hackage: pantry-0.10.0@sha256:6f99ee8d7cfeeb0e2513638618acf80c72d018e7f10120048fa120a409b9dcd2,7864
pantry-tree:
sha256: 820f4442ca96663fa57405f22385d216fbc1a28b9f49c7c82ad2a391803abe51
sha256: 780acb3eaec5c14b3905d5343a8b0152165643634741590a96a5b0d5904a9bcc
size: 2722
original:
hackage: pantry-0.9.3.2@sha256:336373d8cbb10505ff16ac6e35cb9d8a7f45293a908de1c00f55c133ee7dde86,7511
hackage: pantry-0.10.0@sha256:6f99ee8d7cfeeb0e2513638618acf80c72d018e7f10120048fa120a409b9dcd2,7864
- completed:
hackage: process-1.6.18.0@sha256:cd0a3e0376b5a8525983d3131a31e52f9ffefc278ce635eec45a9d3987b8be3e,3025
pantry-tree:
Expand Down

0 comments on commit 1f99734

Please sign in to comment.