Repository navigation
feat(flake): opt-in capability modules on mkProjectShell (native first) - #901
Conversation
`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
left a comment
There was a problem hiding this comment.
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
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, thenativemodule, 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 (plainmkShellstays; no devenv/devshell frameworks).Closes #884
Type of Change
feat-- New featureModifiers
!) -- This change breaks backward compatibilityChanges Made
docs/rfcs/ADR-capability-modules.md: v1 module contract = packages + env vars + shellHook fragments only; composition/precedence rules withextraPackages/shellHook; zero-module byte-identical invariant; migration path to per-module option attrsets; hooks-contribution recorded as an open question for feat(workspace): generate .pre-commit-config.yaml from the flake (git-hooks.nix) — composable base hooks, consumer-extensible in the project flake #883;DEVKIT_MODULES(feat(workspace): persist delivery mode, identity, and modules in .vig-os — declarative manifest with a new "bare" mode #885) cross-referenced as the scaffold-level mapping.mkProjectShell(flake.nix): newmodules ? [ ]argument resolves names against the newnix/modules/registry and folds contributions —packagesappended afterextraPackages(escape hatch wins PATH lookup),envmerged under the builder's own pins (a module can never break the UV_PYTHON bootstrap), shellHook fragments before the consumer hook. One self-contained diff region, merge-friendly for feat(workspace): generate .pre-commit-config.yaml from the flake (git-hooks.nix) — composable base hooks, consumer-extensible in the project flake #883'shooksargument. Unknown names throw with the available list.nativemodule (nix/modules/native.nix):stdenv.cc,cmake,gnumake,pkg-config+ genericCC=cc/CXX=c++exports (via shellHook fragment — stdenv.cc's setup hook would clobber static env attrs). The long-term fix(image): no C/C++ toolchain — uv cannot build sdists for deps without cp314 wheels (CMake reads absent nix-store compiler from sysconfig) #879 answer: the 0.4.1 image sysconfig sanitize makes build backends do PATH discovery; this module provides the PATH.geant4/rust/fortran/rootstay ask-gated candidates (named in docs, not shipped — YAGNI).checks.<system>.module-<name>devshell build per registry entry (a module cannot ship without its check); evaluates on all default systems incl. x86_64-linux and aarch64-linux.tests/test_flake_modules.py— toolchain-on-PATH (env-isolated), generic CC/CXX, and an end-to-end uv sdist build+install of a trivial setuptools C-extension fixture (tests/fixtures/native_ext/) inside the module devshell.modules = [ "native" ]one-liner (hand-rolledextraPackagesstays as the equivalent/escape hatch); worked Geant4/ROOT example updated; NIX.md gains a capability-modules section; explicit statement everywhere that the published image stays base-only.Changelog Entry
Added
mkProjectShell(#884)modules = [ "native" ]composes curated capability modules (packages + env vars + shellHook fragments) onto the project dev-shell; contract recorded indocs/rfcs/ADR-capability-modules.md.extraPackagesremains the per-repo escape hatch and wins PATH lookup.nativemodule ships first (stdenv.cc,cmake,gnumake,pkg-config, genericCC/CXX) — the long-term #879 answer;geant4/rust/fortran/rootstay ask-gated candidates.checks.<system>.module-<name>) plus a uv C-extension sdist smoke test (tests/test_flake_modules.py).Testing
just testsubset relevant to the change)Manual Testing Details
nix eval .#devShells.<sys>.default.drvPathidentical before/after on both Linux systems —vwmxsdhqfrmi986p9agf67cdn9m3dl01-nix-shell.drv(x86_64-linux),p8h7b0svl7kf22rqvsnw23l7f45q4chb-nix-shell.drv(aarch64-linux).tests/test_flake_devshell.pyuntouched and green: 11 passed, 1 skipped (host-gated), 17 s.checks.x86_64-linux.module-nativedid not exist); after the seam landed:tests/test_flake_modules.py3 passed — incl. the sdist smoke (uv build --sdist->uv pip install <sdist>->import native_ext; answer() == 42) inside thenativedevshell.checks.{x86_64-linux,aarch64-linux,aarch64-darwin}.module-native.drvPathall evaluate; x86_64-linux built.nix buildofchecks.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(fullnix flake check+ scaffold-against-local-toolchain) 15 passed, 17 s.unknown capability module 'nope'; available: native.just precommit(prek, all files) green.Checklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
DEVKIT_MODULESin.vig-os) maps onto this flake-level contract; feat(workspace): generate .pre-commit-config.yaml from the flake (git-hooks.nix) — composable base hooks, consumer-extensible in the project flake #883's consumerhooksargument lands beside the seam (module hooks-contribution is the recorded open question in the design note).Refs: #884