Support `build-depends:` injection from `cabal.project`
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
## Proposal
Support the `build-depends:` field in a `cabal.project` file.
For example, this `cabal.project` file:
```cabal
package *
build-depends: ghc-tags-plugin
ghc-options:
-plugin-package=ghc-tags-plugin
-fplugin=Plugin.GhcTags
```
would tell `cabal build` to build every component as if `ghc-tags-plugin` had been added to its `build-depends:`.
## Motivation
I'm looking for a user-friendly way to run *global* GHC plugins [^global] with Cabal.
[^global]: A GHC plugin is *global* if it needs to run on all transitive dependencies of a package. (e.g. [cabal-audit], [ghc-tags-plugin], [ghc-wpc])
[cabal-audit]: https://github.com/TristanCacqueray/cabal-audit
[ghc-tags-plugin]: https://github.com/coot/ghc-tags-plugin
[ghc-wpc]: https://github.com/grin-compiler/ghc-whole-program-compiler-project
Currently, users of [ghc-tags-plugin] are asked to:
1. `cabal install --lib ghc-tags-plugin`
2. Find out where their package-db is
(for me it was `/home/lawrence/.local/state/cabal/store/ghc-9.4.8/package.db/`)
3. Write a `cabal.project` similar to:
```cabal
package *
ghc-options:
-package-db=/home/lawrence/.local/state/cabal/store/ghc-9.4.8/package.db/
-plugin-package=ghc-tags-plugin
-fplugin=Plugin.GhcTags
```
4. `cabal build`
## Related Issues
If #7901 is implemented, `cabal.project` would only need to contain:
```cabal
package *
plugin-depends: ghc-tags-plugin
```
And no `cabal install --lib` call would be required.
Unfortunately, a full implementation of #7901 'will be messy': https://github.com/haskell/cabal/issues/7901#issuecomment-1010141907.
This feature might be easier to implement that #7901, because:
* Cabal already supports `build-depends:` in `.cabal` files
* No GHC-specific details need to be considered (`build-depends:` is compiler-agnositc)
* No plugin-specific details need to be considered (`build-depends:` works with any library)
Contributor guide
Assessment
This issue has not been assessed yet.