Skip to content

Add .small GHC derivation variant and fix Hadrian profiling bug#2481

Open
angerman wants to merge 1 commit intomasterfrom
feature/small-ghc-derivations
Open

Add .small GHC derivation variant and fix Hadrian profiling bug#2481
angerman wants to merge 1 commit intomasterfrom
feature/small-ghc-derivations

Conversation

@angerman
Copy link
Collaborator

Summary

  • Fixes a pre-existing bug where enableLibraryProfiling = false was silently ignored on Hadrian builds (GHC 9.4+): the +no_profiled_libs flavour transformer was only applied for GHCJS/Wasm targets, not when the parameter was set by callers.
  • Adds a new enableHaddockDocs parameter (default true, fully backwards-compatible) that disables Haddock generation for both legacy make and Hadrian builds.
  • Exposes a .small passthru variant on every GHC derivation — following the same pattern as .dwarf and .smallAddressSpace — that disables both profiling libraries and Haddock docs, significantly reducing closure size for CI caches, Docker images, and cross-compilation toolchains.

Changes (compiler/ghc/default.nix)

  • New enableHaddockDocs parameter (default true) — legacy make sets HADDOCK_DOCS=NO; Hadrian uses --docs=nothing instead of --docs=no-sphinx.
  • Hadrian profiling bug fix+no_profiled_libs flavour transformer now applied whenever !enableLibraryProfiling, not only for GHCJS/Wasm targets.
  • Conditional build inputssphinx and hscolour are only included in nativeBuildInputs when enableHaddockDocs = true.
  • .small passthru — sets enableLibraryProfiling = false and enableHaddockDocs = false.

Usage

# Minimal GHC without profiling libs or Haddock — smaller closure for CI/Docker
pkgs.haskell-nix.compiler.ghc967.small

Test plan

  • nix eval .#legacyPackages.x86_64-linux.haskell-nix.compiler.ghc965 --apply 'x: x ? small'true
  • nix eval .#legacyPackages.x86_64-linux.haskell-nix.compiler.ghc965 --apply 'x: x ? dwarf && x ? smallAddressSpace'true (existing variants unaffected)
  • Full build + closure size comparison (expensive, not run locally)

Introduces a .small passthru variant on GHC derivations that opts out of
profiling libraries and Haddock documentation, significantly reducing closure
size for CI, Docker, and cross-compilation toolchain use cases.

Also fixes a pre-existing bug where `enableLibraryProfiling = false` had no
effect on Hadrian builds (GHC 9.4+): the `+no_profiled_libs` flavour
transformer was only applied for GHCJS/Wasm targets, silently ignoring the
parameter for all other platforms.

Changes:
- Add `enableHaddockDocs` parameter (default true, fully backwards-compatible)
- Fix legacy make build: HADDOCK_DOCS=NO now also honours enableHaddockDocs
- Fix Hadrian: +no_profiled_libs applied whenever enableLibraryProfiling=false
- Hadrian: --docs=nothing when enableHaddockDocs=false, no-sphinx otherwise
- Make sphinx and hscolour nativeBuildInputs conditional on enableHaddockDocs
- Add .small passthru variant (enableLibraryProfiling=false, enableHaddockDocs=false)

Usage: pkgs.haskell-nix.compiler.ghc967.small
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