Repository navigation
feat(nix): add sandboxExcludes to mkRustProject's nextest check - #1836
Merged
Merged
Conversation
This was referenced Oct 5, 2026
gerchowl
added a commit
that referenced
this pull request
Oct 5, 2026
…s, mkRustProject flake, #rust template) (#1837) ## Description Ships the Rust pack's missing entry point (#1496: L1, L4, L7). A repo with a `Cargo.toml` now gets a working Rust setup from the scaffold, instead of the Python recipes that skip without a `pyproject.toml` and let CI go green without compiling anything. It also completes #1810's second half: the Rust flake forwards the `.vig-os` hook settings. **Stack 3/6** for #1833. Base: #1836 (`feature/1834-rust-sandbox-test-excludes`). ## Type of Change - [x] `feat` -- New feature - [x] `test` -- Adding or updating tests ## Changes Made **L4: cargo `justfile.project`** (`assets/justfile.d/rust.justfile.project`) - `lint` = `cargo fmt --all --check` + `cargo clippy --workspace --all-targets -- --deny warnings`; `test` = `cargo test --workspace` (doctests included, and the tests `sandboxExcludes` keeps out of the flake check); `sync` = `cargo fetch`; plus `format`, `test-cov` (cargo-llvm-cov), `build`, `update`, `clean-artifacts`. Each recipe reports its skip when `Cargo.toml` is absent (#1478). **L1: base tool configs** (`assets/lang.d/rust/`) - `rustfmt.toml` (stable options only), `clippy.toml` (unwrap/expect allowed in tests), `deny.toml` (permissive licence allow-list, `[licenses.private] ignore = true`, wildcard and unknown-source denial). They are seeded where the repo has none, and they're `PRESERVE_FILES`, so consumer-owned from then on. #1400 settled ownership: the pack owns them, and guardrails' copies defer. - `.cargo/config.toml` is **deliberately not shipped**. Everything it would carry (mold, linker flags) already comes from the flake's rust module, so the file would only be comments. **Rust `flake.nix`** (`assets/flake.d/rust.flake.nix`) - Replaces the fresh `flake.nix` on a first direnv scaffold of a Cargo repo (never an existing one). `rust = vigos.lib.mkRustProject { … }` provides `devShells.default`, and `inherit (rust) checks packages;` keeps statix clean. All five `.vig-os` settings are forwarded behind `functionArgs` probes, because `vigos` floats (#1249). This closes #1810's remaining half. - The managed `.vig-os` reader and the `extraPackages` block are byte-identical to the base stub. `tests/test_rust_scaffold.py` pins that lockstep, so the two stubs can't drift. **Seeding** (`assets/init-workspace.sh`) - `seed_node_justfile_project` became `seed_language_variant <dir> <suffix> <target> <preexisted>`. It serves the Node and Rust `justfile.project` and the Rust `flake.nix` from one code path. Node still wins over Rust, as before. A second language that also ships a variant is named in a notice, never silently dropped. - New `seed_language_statics` walks `lang.d/<lang>/`. - `infer_legacy_mode` also recognises a `mkRustProject` flake as the scaffold stub. - `scripts/sync_manifest.py` stamps the preserved banner on the Rust seed and on every `lang.d` file, with targets derived from the layout. **L7: `nix flake init -t github:vig-os/devkit#rust`** (`templates/rust/`) - Edition-2024 crate with a library, a binary, a doctest, a unit test, an integration test, `[lints]` and a stripped release profile. The README gives the order (template first, then `install.sh`). **Consumer matrix** - `EXPECTED_FAIL[rust]` is removed (c-vigo's acceptance condition on #1496), and the `rust` cell passes. - New `rust-flake` cell: rust fixture in direnv mode, running `nix flake check` (fmt/clippy/nextest/doctest/doc/deny/workspace), the first-commit hooks, then `just sync/lint/test` inside the flake's dev shell. The fixture gains its `Cargo.lock`. - The expected-fail mechanism stays tested through a synthetic marker. ## Changelog Entry ### Added - **Rust cold adoption: a Cargo repo gets a working Rust setup from the scaffold** ([#1496](#1496)) - The first scaffold of a repo with a `Cargo.toml` seeds a cargo `justfile.project`: `just lint` runs `cargo fmt --check` and clippy with warnings denied, and `just test` runs `cargo test --workspace`. It used to get the Python recipes, which skip without a `pyproject.toml`, so CI went green without compiling anything - A fresh direnv scaffold of a Rust repo gets a `flake.nix` on `vigos.lib.mkRustProject` instead of `mkProjectShell`: one call wires the dev shell, the `nix flake check` suite (fmt, clippy, nextest, doctests, rustdoc, cargo-deny, the package builds) and `packages`, and forwards the `.vig-os` hook settings - Base `rustfmt.toml`, `clippy.toml` and `deny.toml` are seeded where the repo has none; they are consumer-owned from then on and never overwritten - New `nix flake init -t github:vig-os/devkit#rust` starter crate that passes the pack's whole check suite as shipped - The consumer matrix's `rust` cell now passes, and a new `rust-flake` cell runs the whole direnv path (`nix flake check`, hooks, `just lint`/`just test` in the flake's shell) on every PR ## Testing - [x] `tests/bats/init-workspace.bats`: 10 new tests (cargo recipes + banner + preserve, statics seeded/scaffold-once/absent for non-Rust, Rust flake seeded/hooks default/knob forwarding/preserve, non-Rust keeps `mkProjectShell`). Full file plus `consumer-matrix.bats`: 345 ok, 0 failed. - [x] `tests/test_rust_scaffold.py`: managed-block and `extraPackages` lockstep, hooks anchor, knob probes, statix shape, and the `#rust` template **built** through every `mkRustProject` check (nextest log: 2 passed). - [x] Local consumer-matrix runs: `rust` passed (fixture suite ran); `rust-flake` passed, with `nix flake check` evaluating and building `clippy deny doc doctest fmt nextest workspace`. - [x] Seeded Rust flake: `deadnix --no-lambda-arg --no-lambda-pattern-names`, `statix check` and `nixfmt --check` are all clean. ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and pasted the entry above) - [x] I have added tests that prove my fix is effective or that my feature works ## Additional Notes - The cold-adoption docs (MIGRATION.md, README) land in #1831 (stack 4/6). The adopter-facing story is complete only with both. Refs: #1496, #1810, #1833
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
mkRustProject'snextestcheck runs inside the Nix build sandbox, where tests that need a PTY, process groups, signals or the network cannot pass. Before this PR a consumer had two options:nextest = false, which also dropped every test the sandbox can run, or an undocumentedcraneArgspatch. This adds a named seam for it.Stack 2/6 for #1833. Base: #1835 (
bugfix/1810-rust-project-hook-knobs).Type of Change
feat-- New featuretest-- Adding or updating testsChanges Made
nix/mk-rust-project.nix: newsandboxExcludes ? [ ], a list of nextest filterset expressions. They are rendered into a single-E 'not (a) and not (b)', because nextest unions repeated-Eflags, so per-exclusion flags would still run everything. The filter is composed with anycargoNextestExtraArgsthe consumer passes throughcraneArgs, never assigned over it.sandboxExcludes must be ….checks.nextestis affected. The excluded tests stay injust testand CI through the Rustjustfile.projectthat Rust pack: L1/L4/L7 never shipped — the pack cannot be adopted cold #1496 (stack 3/6) seeds. The adopter docs for the seam land with Docs: MIGRATION.md says the rust module is unshipped and steers Rust adopters away from mkRustProject #1831 (stack 4/6).Changelog Entry
Added
mkRustProjectsandboxExcludesfor tests the Nix sandbox cannot run (#1834)[ "test(pty_)" "binary(supervisor)" ]) thatchecks.nextestskips, for suites that need a PTY, process groups, signals or the networkjust testand CI; only the sandboxed flake check skips them, so a repo no longer has to choose betweennextest = falseand a rednix flake checkTesting
test_mk_rust_project_sandbox_excludes_skip_tests_in_the_nextest_checkbuildschecks.nexteston a fixture crate whoseneeds_a_ptytest always panics. Without the exclusion the build must fail on that test (the control); withsandboxExcludes = [ "test(needs_a_pty)" ]it must succeed. Only nextest itself can prove that the filter expression matches.…_compose_with_crane_args: two exclusions and a consumer's--no-fail-fastall reach the check phase.…_rejects_a_malformed_sandbox_excludes: a non-list and an empty entry are refused by name.tests/test_flake_modules.py: 36 passed locally.Checklist
CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Refs: #1834, #1833