Skip to content

feat: seed the Rust pack on cold adoption (cargo recipes, tool configs, mkRustProject flake, #rust template) - #1837

Merged
gerchowl merged 7 commits into
devfrom
feature/1496-rust-cold-adoption-entry
Oct 5, 2026
Merged

gerchowl merged 7 commits into
devfrom
feature/1496-rust-cold-adoption-entry

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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

  • feat -- New feature
  • test -- Adding or updating tests

Changes Made

L4: cargo justfile.project (assets/justfile.d/rust.justfile.project)

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. Rust language pack — and reconciling devkit with gerchowl/guardrails #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)

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 Rust pack: L1/L4/L7 never shipped — the pack cannot be adopted cold #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)
    • 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

  • 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.
  • 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).
  • 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.
  • Seeded Rust flake: deadnix --no-lambda-arg --no-lambda-pattern-names, statix check and nixfmt --check are all clean.

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

Additional Notes

Refs: #1496, #1810, #1833

@gerchowl

gerchowl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Follow-ups from an independent review of the stack:

  • Fixed (was a blocker): the base tool configs were seeded on every --force. An existing mkRustProject repo without a deny.toml would have received one on its next devkit-upgrade PR, which silently switches on checks.deny. They are now seeded only for a language this run adopts, meaning it was not declared in .vig-os before. DEVKIT_LANGUAGES and the Rust pack both date from 1.9.0, so every existing pack consumer is covered. Tested: an upgrade of a repo with DEVKIT_LANGUAGES=rust seeds nothing.
  • Never seeded beside an equivalent: .rustfmt.toml, .clippy.toml or .cargo/deny.toml counts as present. Tested.
  • deny.toml: the allow-list now also covers 0BSD, BSL-1.0, CC0-1.0, MIT-0, MPL-2.0 (file-level copyleft), Unicode-DFS-2016 and Unlicense. unknown-git is now warn. A real crate's dependency graph no longer turns cold adoption red on licence noise.
  • The Rust flake now carries the same commented hooks opt-in block as the base stub. direnv-mode scaffold ships hand-managed pre-commit config whose pymarkdown hook cannot run on host runners #1167's inserted comment refers to it, and the lockstep test pins it.

Base automatically changed from feature/1834-rust-sandbox-test-excludes to dev October 5, 2026 21:31
@gerchowl
gerchowl merged commit c7de28b into dev Oct 5, 2026
30 of 33 checks passed
@gerchowl
gerchowl deleted the feature/1496-rust-cold-adoption-entry branch October 5, 2026 21:31
gerchowl added a commit that referenced this pull request Oct 5, 2026
…#1838)

## Description

The adopter docs never led a Rust consumer to the Rust pack, and
`docs/MIGRATION.md` actively steered them away from it: it called `rust`
an unshipped candidate and recommended `extraPackages = [ pkgs.cargo
pkgs.rustc ]`. This PR fixes both passages, adds a Rust section the
scaffold can link to, and has the scaffold print that link when a Rust
repo's preserved files bypass the pack.

**Stack 4/6** for #1833. Base: #1837
(`feature/1496-rust-cold-adoption-entry`).

## Type of Change

- [x] `docs` -- Documentation only
- [x] `feat` -- New feature (the scaffold notice)
- [x] `test` -- Adding or updating tests

## Changes Made

- `docs/MIGRATION.md`
- "Adding tools the image does not ship": Rust goes to the pack and
C/C++ to `native`. The `extraPackages` example keeps only genuinely
ad-hoc tools.
- "The native-build contract": lists the modules that actually ship
(`native`, `node`, `docs`, `guardrails`, `rust`), with `rust` used
through `mkRustProject`.
- New **"Rust projects: the Rust pack"** section: the check table; the
new-repo path (`nix flake init -t #rust`, then `install.sh`) and what
gets seeded; porting a repo scaffolded before it was Rust (pointers to
`assets/flake.d/rust.flake.nix` and the cargo recipes); `toolchainHash`
pinning; `sandboxExcludes` (#1834); the base tool configs and advisories
outside the sandbox.
  - "Declared project languages" names the new Rust seeds.
- `README.md` (via `docs/templates/README.md.j2` + `just docs`) and
`docs/SOLO_ADOPTION.md` link to the section.
- `assets/init-workspace.sh`: `notice_rust_pack_bypass`. In a Rust repo,
it prints a notice when a **preserved** `flake.nix` doesn't use
`mkRustProject`, or a **preserved** `justfile.project` never runs cargo.
Each notice names the gap and links the MIGRATION section. It stays
silent on a fresh scaffold, where #1496's seeds already landed. This is
the issue's "print a notice when `DEVKIT_LANGUAGES` gains `rust`",
scoped to the case that still needs it now that #1496 seeds
automatically.

## Changelog Entry

### Changed
- **Rust adopters are pointed at the Rust pack, not a bare compiler**
([#1831](#1831))
- `docs/MIGRATION.md` no longer calls `rust` an unshipped candidate
module or recommends `extraPackages = [ pkgs.cargo pkgs.rustc ]`; a new
"Rust projects: the Rust pack" section covers the new-repo path, porting
a repo scaffolded before it was Rust, toolchain pinning,
`sandboxExcludes` and the base tool configs. `README.md` and
`docs/SOLO_ADOPTION.md` link to it
- The scaffold prints a notice when a Rust repo keeps a preserved
`flake.nix` that does not use `mkRustProject`, or a `justfile.project`
that never runs cargo, naming the doc section that fixes it

## Testing

- [x] 3 bats tests: the flake notice, the justfile notice, and no notice
on a fresh Rust scaffold. They failed before the implementation.
- [x] `test_bypass_notice_links_to_a_real_migration_heading`: every
`docs/MIGRATION.md#…` anchor in `init-workspace.sh` resolves to a real
heading. It failed until the section existed.
- [x] All `#1496|#1831` bats tests pass locally.

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have updated the documentation accordingly (edit
`docs/templates/`, then run `just docs`)
- [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

Refs: #1831, #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