Skip to content

feat(flake): opt-in capability modules on mkProjectShell (native first) - #901

Merged
c-vigo merged 6 commits into
devfrom
feature/884-capability-modules
Jul 7, 2026
Merged

c-vigo merged 6 commits into
devfrom
feature/884-capability-modules

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Implements the modular capability layer on top of mkProjectShell (#884): consumers declare capabilities (modules = [ "native" ]) instead of hand-picking packages. Ships the v1 contract design note, the composition seam, the native module, per-module flake checks, a uv C-extension sdist smoke test, and consumer docs. Builder-level decisions from ADR-nix-devenv-strategy are not reopened (plain mkShell stays; no devenv/devshell frameworks).

Closes #884

Type of Change

  • feat -- New feature

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

Changelog Entry

Added

  • Opt-in capability modules for mkProjectShell (#884)
    • modules = [ "native" ] composes curated capability modules (packages + env vars + shellHook fragments) onto the project dev-shell; contract recorded in docs/rfcs/ADR-capability-modules.md.
    • Zero-module shells are byte-identical to the previous builder and the published image stays base-only; extraPackages remains the per-repo escape hatch and wins PATH lookup.
    • native module ships first (stdenv.cc, cmake, gnumake, pkg-config, generic CC/CXX) — the long-term #879 answer; geant4/rust/fortran/root stay ask-gated candidates.
    • Per-module flake checks (checks.<system>.module-<name>) plus a uv C-extension sdist smoke test (tests/test_flake_modules.py).

Testing

  • Tests pass locally (just test subset relevant to the change)
  • Manual testing performed (describe below)

Manual Testing Details

  • Zero-module parity (byte-identical): nix eval .#devShells.<sys>.default.drvPath identical before/after on both Linux systems — vwmxsdhqfrmi986p9agf67cdn9m3dl01-nix-shell.drv (x86_64-linux), p8h7b0svl7kf22rqvsnw23l7f45q4chb-nix-shell.drv (aarch64-linux). tests/test_flake_devshell.py untouched and green: 11 passed, 1 skipped (host-gated), 17 s.
  • Module tests (TDD): committed RED first (checks.x86_64-linux.module-native did not exist); after the seam landed: tests/test_flake_modules.py 3 passed — incl. the sdist smoke (uv build --sdist -> uv pip install <sdist> -> import native_ext; answer() == 42) inside the native devshell.
  • Module check eval on both systems (+darwin): checks.{x86_64-linux,aarch64-linux,aarch64-darwin}.module-native.drvPath all evaluate; x86_64-linux built.
  • Flake gates: nix build of checks.x86_64-linux.{module-native,devShell,deadnix,statix,devShellTools,formatting,pre-commit} green (7.8 s warm); tests/test_flake_checks.py + tests/test_downstream_flake.py (full nix flake check + scaffold-against-local-toolchain) 15 passed, 17 s.
  • Error path: unknown module name throws unknown capability module 'nope'; available: native.
  • Hooks: full just precommit (prek, all files) green.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Refs: #884

c-vigo added 5 commits July 7, 2026 15:04
`modules = [ "<name>" ]` resolves curated capability modules from the
new nix/modules/ registry (v1 contract: packages + env + shellHook
fragments, per docs/rfcs/ADR-capability-modules.md) and merges their
contributions after extraPackages and before the consumer shellHook.
The zero-module shell stays byte-identical to the previous builder
(drvPath unchanged on x86_64-linux and aarch64-linux) and the published
image stays base-only. Ships the native module (stdenv.cc, cmake,
gnumake, pkg-config, generic CC/CXX exports) plus generated per-module
flake checks module-<name> on every default system.

Refs: #884

@c-vigo c-vigo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: reproduced the zero-module parity claim independently (nix eval .#devShells.{x86_64,aarch64}-linux.default.drvPath identical between dev and this branch — vwmxsd… / p8h7b0…, and still identical after merging with post-#899 dev, which merges clean). git diff -w confirms the flake.nix re-indent is purely mechanical; seam precedence matches the design note; test_flake_devshell.py untouched and green; all 3 module tests pass locally incl. the sdist smoke; registry-generated checks pick up new modules automatically.

One gap: tests/test_flake_modules.py is not wired into any CI lane. The nix job gates only the module-native devshell build (nix-fast-build over checks), so the module's behavioral contract — CC/CXX exports (the setup-hook-clobber subtlety most likely to regress) and the sdist compile — never runs in CI. The job already runs a hand-picked test_flake_devshell.py -k … subset with exactly the applicable rationale ("these drive nix develop directly … run them explicitly here where Nix + the dev profile are warm"). Suggest adding at least the two pure tests (no network) to that step; the sdist smoke also works on GH runners (PyPI reachable). Fine as a fast-follow if you'd rather keep this PR frozen.

Refs: #884

@c-vigo
c-vigo merged commit 90eb682 into dev Jul 7, 2026
15 checks passed
@c-vigo
c-vigo deleted the feature/884-capability-modules branch July 7, 2026 13:38
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