Add useLocalGhcLib project option#2510
Merged
Merged
Conversation
Surface what `modules/configuration-nix.nix` used to do unconditionally as an opt-in `useLocalGhcLib` flag, so the `packages.ghc.src` override only fires when a project actually constrains the `ghc` package (e.g. `ghc-lib-reinstallable`). Four pieces: * `modules/project-common.nix`: add the `useLocalGhcLib` option (default `false`). * `modules/configuration-nix.nix`: drop the unconditional `packages.ghc.src` / `packages.ghc.package-description-override` overrides — they're moved into the per-project wiring below. * `modules/stack-project.nix`: under `useLocalGhcLib`, re-apply the `packages.ghc.src` post-plan override. Stack-to-nix can't use the cabal-project route, so this keeps the existing behaviour for stack users who flip the flag. * `modules/cabal-project.nix`: under `useLocalGhcLib`, inject a `source-repository-package` block into `cabalProjectLocal` pointing at the configured-src + generated GHC tree, and add an `inputMap` entry so haskell.nix doesn't try to fetch the URL. Cabal then hashes the wrapped repo's content into `pkg-src-sha256` and installs `lib:ghc` like any other reinstallable dep. Projects that need the previous always-on behaviour now set `useLocalGhcLib = true` on the project module; everyone else gets a smaller plan-nix and avoids the unconditional `configured-src` materialisation. Pulled out of #2504 (`hkm/builder-v2`).
Flips the new opt-in flag in both test variants and adds a changelog entry telling users to do the same when they constrain `lib:ghc`.
hamishmack
added a commit
that referenced
this pull request
May 25, 2026
Migrates the in-tree test suite to work under `builderVersion = 2`.
Adds `docs/dev/migrating-to-v2.md` documenting the patterns we hit,
keyed off the symptoms users are likely to see when flipping the
flag on their own projects.
Patterns covered (with file-level examples):
* Library / executable profiling — `.profiled` overlay replaced by
a sibling project whose `cabalProjectLocal` carries
`library-profiling: True` / `profiling: True`
(`test/exe-dlls`, `test/exe-lib-dlls`, `test/gi-gtk`,
`test/th-dlls`, `test/th-dlls-minimal`, `test/js-template-haskell`,
`test/cabal-simple-prof`).
* Coverage — module-level `doCoverage` mirrored into
`cabalProjectLocal` `coverage: True` (`test/coverage`).
* DWARF — `.dwarf` overlay dropped, replaced by
`compilerSelection = … c.dwarf …` + `debug-info: 2`
(`test/cabal-simple-debug`).
* Sublib haddock — `documentation: True` in `cabalProjectLocal`;
output path moved so `find -name <Module.html>` accepts both v1
and v2 layouts (`test/sublib-docs`).
* Per-package `ghc-options` — `HsOpenSSL` workaround moved from
`test/modules.nix` to `test/cabal.project.local` (`test/modules.nix`).
* Per-package `extra-lib-dirs` — Windows `test-clib` paths moved
into `cabalProjectLocal` (`test/th-dlls-minimal`).
* `ghcOptions` scope — moved from per-component to per-package
(`test/th-dlls`).
* `shellFor` migration — `component.shell` / `component.env` →
`project.shellFor { exposePackagesVia = "ghc-pkg"; }`
(`test/with-packages`, `test/shell-for`,
`test/shell-for-setup-deps`).
* `withHoogle = false` on static — avoids `.dyn_hi` lookup failures
in hoogle's haddock chain (`test/with-packages`).
* `origSrc` / `origSubDir` workaround — synthesised package-root
drv with `.git` at the top, source-cleaning disabled via
`outPath` + `filterPath` (`test/githash`).
* Custom-setup `base` / `directory` — added to explicit
`setup-depends` (`test/setup-deps`, `test/shell-for-setup-deps`).
* Native-musl `git` — host vs build-build picker keyed on
`haskellLib.isNativeMusl` to avoid glibc/musl libc mixing
(`test/githash`).
* Android cross — `test/cabal.project.android` injected
conditionally (`test/exe-dlls`, `test/exe-lib-dlls`,
`test/th-dlls`).
* `useLocalGhcLib = true` — earlier change (PR #2510) covered
separately; referenced in the guide for completeness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Surfaces what
modules/configuration-nix.nixused to do unconditionally as an opt-inuseLocalGhcLibflag. Thepackages.ghc.srcoverride now only fires when a project actually constrains theghcpackage (e.g.ghc-lib-reinstallable).Four pieces:
modules/project-common.nix— add theuseLocalGhcLiboption (defaultfalse).modules/configuration-nix.nix— drop the unconditionalpackages.ghc.src/packages.ghc.package-description-overrideoverrides; they're moved into the per-project wiring below.modules/stack-project.nix— underuseLocalGhcLib, re-apply thepackages.ghc.srcpost-plan override. Stack-to-nix can't use the cabal-project route, so this keeps the existing behaviour for stack users who flip the flag.modules/cabal-project.nix— underuseLocalGhcLib, inject asource-repository-packageblock intocabalProjectLocalpointing at the configured-src + generated GHC tree, and add aninputMapentry so haskell.nix doesn't try to fetch the URL. Cabal then hashes the wrapped repo's content intopkg-src-sha256and installslib:ghclike any other reinstallable dep.Projects that need the previous always-on behaviour now set
useLocalGhcLib = trueon the project module; everyone else gets a smaller plan-nix and avoids the unconditionalconfigured-srcmaterialisation.Pulled out of #2504 (
hkm/builder-v2).