Inject platform-conditional cabalProjectLocal defaults#2511
Merged
Conversation
c8d6208 to
cccded1
Compare
…cal defaults
Two related changes to `modules/cabal-project.nix`:
**1. `cabalProjectLocal` / `cabalProjectFreeze` no longer auto-load
from disk.** The options were typed `nullOr lines` with
`readIfExists`-based defaults that did IFD lookups for
`cabal.project.local` / `cabal.project.freeze` in the project
source. Internal projects (hadrian, ghc-extra-projects) explicitly
set them to `null` just to suppress those reads, and the nullability
also prevented `mkBefore` directives from merging cleanly.
Switch the types to plain `lines` (default `""`) — projects that
relied on the implicit `readFile` behaviour now do it explicitly:
cabalProjectLocal = builtins.readFile ./cabal.project.local;
Internal callers that set `null` for IFD-avoidance lose the
explicit assignments — the new default is already IFD-free.
**2. Platform-conditional defaults are now injected into every
cabal project's `cabalProjectLocal`.** Four `mkIf` blocks added:
* **musl host** — `package * \n executable-static: True`.
comp-builder adds `--ghc-option=-optl=-static` at build time;
surfacing the toggle here makes plan-to-nix record
`--enable-executable-static`. Build artefacts are unchanged.
* **x86_64-darwin host** — `package * \n library-for-ghci: True`.
Mirrors what comp-builder passes for `!ghcjs && !wasm && !android`
(always true on darwin).
* **android host** —
`package * \n ghc-options: -optl-static -optl-ldl` (plus
`-optl-no-pie` on aarch32). Mirrors `lib/check.nix`'s
test-exe `setupBuildFlags` re-wrap.
* **wasm GHC ≥ 9.12** — `package * \n shared: True`. Wasm's RTS
linker only loads `.so` files; `--disable-shared` (cabal's
default given the real compiler's reported capabilities) would
force a `.a`-only install that TH-eval can't load.
All four sit at `mkBefore` priority so a project's own
`cabalProjectLocal` overrides them.
Cache impact: plan-nix hashes change for affected platforms.
Internal GHC builds verified byte-identical (drvPath
`na9chax1gj2n6jx3d6v86v6fdah9r9fd-ghc-9.14.1.drv` matches master).
Changelog entry added describing both changes.
Pulled out of #2504 (`hkm/builder-v2`).
cccded1 to
dad52b0
Compare
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 the static-linking / library-for-ghci / shared-libs flags that comp-builder and
lib/check.nixalready apply at the artefact level into the plan-to-nix step, so plan-nix's recorded configure-args and UnitIds match what cabal v2-build would compute against the real compiler.Four mkIfs added to
modules/cabal-project.nix:package * \n executable-static: True. comp-builder adds--ghc-option=-optl=-staticat build time; surfacing the toggle here makes plan-to-nix record--enable-executable-static. Build artefacts are unchanged.package * \n library-for-ghci: True. Mirrors what comp-builder passes for!ghcjs && !wasm && !android(always true on darwin).package * \n ghc-options: -optl-static -optl-ldl(plus-optl-no-pieon aarch32). Mirrorslib/check.nix's test-exesetupBuildFlagsre-wrap.package * \n shared: True. Wasm's RTS linker only loads.sofiles;--disable-shared(cabal's default given the real compiler's reported capabilities) would force a.a-only install that TH-eval can't load.All four directives sit at
mkBeforepriority so a project's owncabalProjectLocaloverrides them.Pulled out of #2504 (
hkm/builder-v2).