diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-14 20:54:16 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-14 20:54:16 -0500 |
| commit | 8baf00d3f7e87b24d735f57fd489ab7210f1b7a9 (patch) | |
| tree | 325cbba4b41b52a6002bc53f47985d52b653c21e /Omni/Bild/Example.rs | |
| parent | 05e9c79a6a7b8f13835398342b6f2d26417da946 (diff) | |
Implement per-module Nix derivations for incremental Haskell builds
This is the core architecture transformation from Phase 3 of the
performance plan. Each Haskell module is now built as a separate
Nix derivation, enabling true incremental builds where only changed
modules and their dependents are rebuilt.
Implementation: - buildHsModuleGraph: Analyzes transitive module
dependencies and builds DAG - TH detection: Falls back to monolithic
build if Template Haskell detected - SCC cycle detection: Falls
back if import cycles found - Per-module Nix builder: Each module ->
separate derivation with .hi and .o - Module dependencies: Copy .hi
files to build dir, use -i flags for imports - Final link: Use ghc
--make with entry point source + -i paths to .hi files - Entry point
fix: Explicitly analyze entry point module separately from deps
Architecture: - Module compilation: ghc -c with -i paths to dependency
.hi files - Source filtering: Each module derivation includes only
its source file - Dependency DAG: Expressed as recursive Nix attrset
with lib.fix - Link phase: ghc --make with entry source file + all .hi
search paths - Fallback: Monolithic ghc --make when hsGraph is null
(TH/cycles)
Performance characteristics: - Change one module -> rebuild only
that + dependents + relink - Nix handles DAG scheduling and caching
automatically - Parallel module compilation (Nix orchestrates) -
Content-addressed caching across machines
Testing: - Added test_buildHsModuleGraph unit test - Verified with
Omni/Bild/Example.hs (4 modules) - Tested incremental rebuild triggers
correct subset
This completes Phase 2 and Phase 3 core optimizations from the plan.
Diffstat (limited to 'Omni/Bild/Example.rs')
0 files changed, 0 insertions, 0 deletions
