Skip to content

Inject platform-conditional cabalProjectLocal defaults#2511

Merged
hamishmack merged 1 commit into
masterfrom
hkm/v1-platform-cabal-project-defaults
May 23, 2026
Merged

Inject platform-conditional cabalProjectLocal defaults#2511
hamishmack merged 1 commit into
masterfrom
hkm/v1-platform-cabal-project-defaults

Conversation

@hamishmack
Copy link
Copy Markdown
Collaborator

Surfaces the static-linking / library-for-ghci / shared-libs flags that comp-builder and lib/check.nix already 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:

  • musl hostpackage * \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 hostpackage * \n library-for-ghci: True. Mirrors what comp-builder passes for !ghcjs && !wasm && !android (always true on darwin).
  • android hostpackage * \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.12package * \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 directives sit at mkBefore priority so a project's own cabalProjectLocal overrides them.

⚠️ Cache impact: plan-nix hashes change for affected platforms on the next CI run — one rebuild wave. Changelog entry describes the opt-out path.

Pulled out of #2504 (hkm/builder-v2).

@hamishmack hamishmack force-pushed the hkm/v1-platform-cabal-project-defaults branch from c8d6208 to cccded1 Compare May 23, 2026 11:09
…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`).
@hamishmack hamishmack force-pushed the hkm/v1-platform-cabal-project-defaults branch from cccded1 to dad52b0 Compare May 23, 2026 11:09
@hamishmack hamishmack merged commit ddc0742 into master May 23, 2026
6759 of 6799 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant