Skip to content

feat(nix): add sandboxExcludes to mkRustProject's nextest check - #1836

Merged
gerchowl merged 2 commits into
devfrom
feature/1834-rust-sandbox-test-excludes
Oct 5, 2026
Merged

gerchowl merged 2 commits into
devfrom
feature/1834-rust-sandbox-test-excludes

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

mkRustProject's nextest check 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 undocumented craneArgs patch. 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 feature
  • test -- Adding or updating tests

Changes Made

Changelog Entry

Added

  • mkRustProject sandboxExcludes for tests the Nix sandbox cannot run (#1834)
    • A list of nextest filterset expressions (e.g. [ "test(pty_)" "binary(supervisor)" ]) that checks.nextest skips, for suites that need a PTY, process groups, signals or the network
    • The excluded tests stay in just test and CI; only the sandboxed flake check skips them, so a repo no longer has to choose between nextest = false and a red nix flake check

Testing

  • test_mk_rust_project_sandbox_excludes_skip_tests_in_the_nextest_check builds checks.nextest on a fixture crate whose needs_a_pty test always panics. Without the exclusion the build must fail on that test (the control); with sandboxExcludes = [ "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-fast all 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

  • 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 CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • I have added tests that prove my fix is effective or that my feature works

Refs: #1834, #1833

@gerchowl gerchowl self-assigned this Oct 5, 2026
Base automatically changed from bugfix/1810-rust-project-hook-knobs to dev October 5, 2026 21:31
@gerchowl
gerchowl merged commit fa48132 into dev Oct 5, 2026
16 checks passed
@gerchowl
gerchowl deleted the feature/1834-rust-sandbox-test-excludes branch October 5, 2026 21:31
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
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