Skip to content

fix: let the upgrade preflight pass untracked output the upgrade will ignore - #1839

Merged
gerchowl merged 4 commits into
devfrom
bugfix/1826-preflight-untracked-build-output
Oct 5, 2026
Merged

gerchowl merged 4 commits into
devfrom
bugfix/1826-preflight-untracked-build-output

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

The install.sh --force preflight refused any untracked file. A repo that had just gained a language, such as a Rust repo with cargo build output in target/, therefore could not take the very upgrade that adds the .gitignore fragment ignoring it. The workaround was to move the build directory aside. Same for node_modules/, .venv/ and Nix result links.

Stack 5/6 for #1833. Base: #1838 (feature/1831-rust-pack-adopter-docs).

Type of Change

  • fix -- Bug fix
  • test -- Adding or updating tests

Changes Made

The judgement moves to where the knowledge is. The host doesn't know the gitignore fragments or the detected languages; the image does.

  • install.sh (host): tracked changes still refuse, unchanged. Untracked paths (git ls-files --others --exclude-standard --directory) are no longer refused host-side. They are forwarded to the container as DEVKIT_PREFLIGHT_UNTRACKED. New --allow-untracked flag skips that check: it names the paths it leaves out, and tracked changes still refuse.
  • assets/init-workspace.sh (container): preflight_untracked_guard runs right after language detection, before any file is written. It assembles the root .gitignore this run will write (template base + the detected languages' gitignore.d fragments + .gitignore.project, the same parts render_gitignore uses) and matches each path with git's own matcher (check-ignore --no-index) in a scratch repo, because the workspace's .git may be an unmounted worktree pointer. Covered paths are named and left in place. Any other path refuses by name and hints --allow-untracked / --skip-preflight.
  • Build output of a language that isn't detected is not excused (node_modules/ without a package.json), because its fragment won't be in the upgraded .gitignore.
  • docs/MIGRATION.md "Upgrade preflight guard and preview" documents the rule and the flag.

Changelog Entry

Fixed

  • Untracked build output no longer blocks the upgrade that ignores it (#1826)
    • The install.sh --force preflight refused any untracked file, so a repo that had just gained a language (a Rust repo with target/) could not take the very upgrade that adds its .gitignore fragment. Untracked paths are now matched against the .gitignore the upgrade will write; covered ones are named and left in place, any other one still refuses, by name
    • New --allow-untracked flag runs the upgrade with untracked files present; tracked changes still refuse

Testing

  • install.bats (5 new, 1 rewritten): untracked paths are forwarded rather than refused; a tracked change still refuses alongside target/; --allow-untracked proceeds and forwards nothing; --allow-untracked doesn't excuse a tracked change; a clean tree forwards nothing. All 30 preflight tests pass.
  • init-workspace.bats (4 new): a Rust repo's target/ passes while an untracked Cargo.toml is named; an uncovered path refuses before .vig-os or justfile exist; node_modules/ without package.json refuses; .gitignore.project entries count as covered.
  • The issue's repro (neutral scaffold, then Cargo.toml + cargo build, then install.sh --force) is the first init-workspace test.

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
  • 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: #1826, #1833

@gerchowl gerchowl self-assigned this Oct 5, 2026
@gerchowl
gerchowl force-pushed the feature/1831-rust-pack-adopter-docs branch from 85398ce to b2fb0ab Compare October 5, 2026 19:32
@gerchowl
gerchowl force-pushed the bugfix/1826-preflight-untracked-build-output branch from fd9b513 to 3aabb08 Compare October 5, 2026 19:36
@gerchowl

gerchowl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Follow-ups from an independent review:

Stack tip verified locally: init-workspace.bats + install.bats + consumer-matrix.bats 470 ok; Rust/flake pytest 90 passed; consumer-matrix rust and rust-flake cells passed.

@gerchowl
gerchowl force-pushed the feature/1831-rust-pack-adopter-docs branch from b2fb0ab to 9683956 Compare October 5, 2026 19:41
@gerchowl
gerchowl force-pushed the bugfix/1826-preflight-untracked-build-output branch 2 times, most recently from f23c976 to 388cadb Compare October 5, 2026 20:43
Base automatically changed from feature/1831-rust-pack-adopter-docs to dev October 5, 2026 21:32
@gerchowl
gerchowl merged commit aa78c80 into dev Oct 5, 2026
26 of 29 checks passed
@gerchowl
gerchowl deleted the bugfix/1826-preflight-untracked-build-output branch October 5, 2026 21:32
gerchowl added a commit that referenced this pull request Oct 5, 2026
## Description

A flake that consumes a devkit project's `packages` (e.g. one binary
from a Rust CLI built by `mkRustProject`) inherits devkit's whole input
tree in its lock: home-manager twice, git-hooks, treefmt,
process-compose, services-flake and a second nixpkgs. This PR documents,
and puts under test, how the **consuming** flake avoids that.

**Stack 6/6** for #1833. Base: #1839
(`bugfix/1826-preflight-untracked-build-output`).

## Type of Change

- [x] `docs` -- Documentation only
- [x] `test` -- Adding or updating tests

## Changes Made

The issue offered two remedies. I measured before choosing:

| downstream flake | lock nodes | package store path |
| --- | --- | --- |
| plain `my-tool.url` | 17 | `…b87d0…-consumer_matrix_rust-0.1.0` |
| + `nixpkgs` follows (the issue's dedupe stanza) | 17 (nixpkgs is now
the consumer's) | same |
| + `follows = ""` on the 7 devkit inputs packages never read | **8** |
**same** |

- **Docs (taken):** new `docs/MIGRATION.md` section "Projects that ship
packages to other flakes", with the full consumer stanza: build with the
consumer's nixpkgs, and empty the seven unused devkit inputs with Nix's
`follows = ""` idiom. That leaves `nixpkgs`, `crane`, `fenix` and
`flake-utils`. The two stub flakes (`assets/workspace/flake.nix`,
`assets/flake.d/rust.flake.nix`) get a comment pointing there.
- **Template flip (not taken):** making `vigos` follow the project's
`nixpkgs` would re-pin devkit's tools, overlay and dev shell onto a
nixpkgs devkit never tested or cached. The issue's own caveat says this
needs a guard. Since the consumer-side stanza fully solves the reported
problem, the flip isn't needed. The rationale is in the doc section.
- **Contract test** `tests/test_flake_package_consumers.py`:
- It executes the documented block **verbatim** from MIGRATION.md, only
swapping in local URLs, against a project rendered from the `#rust`
template plus the seeded `mkRustProject` flake, with `vigos` overridden
to this checkout. It must build.
- A second test asserts that the stanza's drop list equals devkit's
inputs minus the four a package needs. A new devkit input therefore
fails CI until the doc covers it.

## Changelog Entry

### Changed
- **Documented, tested stanza for flakes that consume a devkit project's
packages** ([#1832](#1832))
- New `docs/MIGRATION.md` section "Projects that ship packages to other
flakes": the consuming flake builds the package with its own nixpkgs and
drops the devkit inputs a package build never reads (`follows = ""`), so
its lock shrinks from devkit's whole input tree to `nixpkgs`, `crane`,
`fenix` and `flake-utils`
- CI builds a Rust project's package through that exact block, and fails
if devkit adds an input the stanza does not cover or starts reading one
it drops. The scaffolded `flake.nix` keeps following devkit's nixpkgs,
and points at the section

## Testing

- [x] Both tests failed first (no documented stanza), then passed.
- [x] Negative control: temporarily adding `crane.follows = ""` to the
doc block makes the build test fail with `attribute 'mkLib' missing`.
The test catches a real dependency, not just an evaluation.
- [x] `tests/test_rust_scaffold.py` (the managed-block lockstep across
both stubs) still passes.

## Checklist

- [x] I have performed a self-review of my code
- [x] I have updated the documentation accordingly
- [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: #1832, #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