Skip to content

docs: document how a flake consumes a devkit project's packages - #1840

Merged
gerchowl merged 3 commits into
devfrom
feature/1832-flake-package-consumers
Oct 5, 2026
Merged

gerchowl merged 3 commits into
devfrom
feature/1832-flake-package-consumers

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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

  • docs -- Documentation only
  • 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)
    • 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

  • Both tests failed first (no documented stanza), then passed.
  • 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.
  • tests/test_rust_scaffold.py (the managed-block lockstep across both stubs) still passes.

Checklist

  • I have performed a self-review of my code
  • 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: #1832, #1833

@gerchowl gerchowl self-assigned this Oct 5, 2026
@gerchowl
gerchowl force-pushed the bugfix/1826-preflight-untracked-build-output branch from fd9b513 to 3aabb08 Compare October 5, 2026 19:36
@gerchowl
gerchowl force-pushed the feature/1832-flake-package-consumers branch from 4555df5 to 047c6d0 Compare October 5, 2026 19:39
@gerchowl
gerchowl force-pushed the bugfix/1826-preflight-untracked-build-output branch from 3aabb08 to f23c976 Compare October 5, 2026 19:41
@gerchowl
gerchowl force-pushed the feature/1832-flake-package-consumers branch from 047c6d0 to 07f13a4 Compare October 5, 2026 19:41
@gerchowl
gerchowl force-pushed the bugfix/1826-preflight-untracked-build-output branch from f23c976 to 388cadb Compare October 5, 2026 20:43
@gerchowl
gerchowl force-pushed the feature/1832-flake-package-consumers branch from 07f13a4 to b92faa5 Compare October 5, 2026 20:45
Base automatically changed from bugfix/1826-preflight-untracked-build-output to dev October 5, 2026 21:32
@gerchowl
gerchowl merged commit b28a2ee into dev Oct 5, 2026
17 of 18 checks passed
@gerchowl
gerchowl deleted the feature/1832-flake-package-consumers branch October 5, 2026 21:32
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