Repository navigation
fix: forwarded content overwritten across scopes (#583) - #585
Merged
Merged
Conversation
A complex forward firing at a child (user) scope merges its own-scope source modules with the root (host) scope's `fromClass` content. The root content was unconditionally filtered to `@default`-keyed modules, silently dropping the host's own contribution. That filter is correct for entity-owned classes — the home-manager battery's `homeManager` forward must not implicitly pull a host's own home config into every user (that projection is opt-in via host-aspects). It is wrong for a custom forward-only class like `atuin`, whose host-scope content exists solely to be aggregated. Filter root modules to `@default` only when `fromClass` is owned by an entity in the scope chain (`user.classes`, `host.class`, `home.class`); otherwise pull the root content in full.
sini
enabled auto-merge (squash)
June 1, 2026 17:56
sini
disabled auto-merge
June 1, 2026 17:56
sini
enabled auto-merge (squash)
June 1, 2026 17:56
drupol
approved these changes
Jun 1, 2026
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.
Problem
Fixes #583. When two aspects contribute to the same forward source class and the forward fires at a child (user) scope while routing into a parent (host) class, the host's own contribution is silently dropped:
Produces
programs.atuin.flags = [ "--hello" ]instead of the merged[ "--hello" "--world" "--baz" ].Worked in v0.16; regressed with the fx-pipeline rewrite (#475).
Root cause
route/apply.nix:getCollectedSourcemerges a complex forward's own-scope source modules with the root (host) scope'sfromClasscontent, but filtered the root content unconditionally throughisDenDefaultModule— keeping only@default-keyed modules. The host's ownatuincontent (module keyatuin@igloo) is not aden.defaultmodule, so it was filtered out, leaving only the user-scope--hello.That
@default-only filter is correct for entity-owned classes: the home-manager battery'shomeManager → nixosforward must not implicitly pull a host's ownhomeManagerconfig into every user's home — that projection is opt-in viahost-aspects. It is wrong for a custom forward-only class likeatuin, whose host-scope content exists solely to be aggregated.Fix
Restrict root content to
@defaultonly whenfromClassis a class an entity in the scope chain owns (user.classes,host.class,home.class, read fromscopeContexts); otherwise keep the root content in full. The owned-class set is total over all three entity kinds so the decision never falls open for a non-user-owned scope.The discriminator keys on
fromClassrather thanintoClassdeliberately —host-aspects.test-opt-in-onlyanduser-host-mutual-config.test-host-owned-unidirectionalboth forwardhomeManagerintonixosyet must keep their opt-in projection semantics.Validation
deadbugs/issue-583-forwarding-overwrite.nix(mirrors the report): overwrite → ✅ 1/1host-aspects✅ 10/10 anduser-host-mutual-config✅ 9/9 — opt-in projection unchanged