Repository navigation
fix: route wrapping merge semantics and forward ordering - #574
Merged
Merged
Conversation
…enful#572) wrapRouteModules previously wrapped each source module independently through nestWithAdaptArgs, producing separate config definitions at the same flake output path. The freeform `unspecified` type shallow-merged these with `//`, so only the last aspect's values survived. Combine all source modules into a single evalModules call for the nestWithAdaptArgs path so the module system merges them properly.
drupol
approved these changes
May 29, 2026
theutz
reviewed
May 29, 2026
…ul#567) When a class forwarder with `each` is imported from a provide aspect, it registers multiple forward routes (e.g. nix→homeManager and nix→nixos). The HM battery route (homeManager→nixos) was firing before nix→homeManager, so it consumed from the homeManager class before the forward had produced into it. Add topoSortRoutes to partition complex forwards: routes whose intoClass feeds another forward's fromClass fire first. Also switch nestWithAdaptArgs freeform type from `unspecified` to `raw` so overlapping keys from different aspects error instead of silently clobbering.
sini
force-pushed
the
fix/572-packages-merge-clobber
branch
from
May 29, 2026 20:44
bf229ab to
fc267ea
Compare
theutz
approved these changes
May 29, 2026
theutz
left a comment
Collaborator
There was a problem hiding this comment.
Pending passing CI, LGTM!
drupol
approved these changes
May 29, 2026
theutz
reviewed
May 29, 2026
| else | ||
| # Same entity via multiple policy paths: keep last. | ||
| [ (lib.last entries) ]; | ||
| # Same entity via multiple policy paths: deduplicate. |
sini
force-pushed
the
fix/572-packages-merge-clobber
branch
2 times, most recently
from
May 29, 2026 21:22
764ee10 to
242192f
Compare
disambiguatedModules silently kept only the last instantiate spec when multiple targeted the same output path on the same system. Add a lib.warnIf so users are alerted when one entity's config shadows another.
sini
force-pushed
the
fix/572-packages-merge-clobber
branch
from
May 29, 2026 22:01
242192f to
85b20cc
Compare
sini
added a commit
that referenced
this pull request
Sep 4, 2026
Closes #674 ## Summary `mergeableType` — the freeform type route nesting evaluates modules under — deep-merges attrsets, concatenates lists, and throws on everything else. Derivations are deliberately excluded from the attrset branch so they stay opaque, so two aspects producing the same package fell to the conflict throw even though the definitions agreed. Same for the reported `enable = true` shape, where deep-merging descends to a scalar leaf with two definitions. - Accepts all-equal definitions before the conflict throw, matching NixOS's `mergeEqualOption`. Checked last, so it forces values only on the path that already threw. #574 introduced the type claiming NixOS module semantics, but `mergeEqualOption` accepts agreeing definitions and only throws on disagreement — so the divergence is latent from #574, and #671 made the path reachable, which is the reporter's own reading of the bisect. This is the same collapse-agreeing-definitions rule #671 applied to `meta.provider`, now on the route freeform type. Testing: - Adds the reported case verbatim (two aspects, one shared derivation), the reported symptom shape (a scalar leaf reached by deep-merging an `apps` attrset defined by two aspects), and a negative control pinning that disagreeing definitions still throw. ## Validation - `nix develop -c just ci`: 1118/1118, exit 0, zero failures and zero errors. `nix develop -c just fmt` a no-op at the final rev. - Reproduced first on an unfixed `origin/main` worktree at 36c8ba5: the issue's test verbatim fails with `den: the option 'shared' has conflicting definitions from multiple aspects`, so the fix is measured against a red baseline rather than a green assumption. - Probed the negative control rather than trusting its pass. Forcing the value without `tryEval` prints that same conflict error, so it fails for the guard's reason and not incidentally. - Confirmed the new suite is discovered by the CI harness with `just ci deadbugs-issue-674` (3/3). The background `just ci` log truncates to 42 lines, so the suite's absence from that log is not evidence either way and was not read as such. ## Known limitation The equality check cannot reach function-valued leaves. Measured against this nixpkgs: | expression | result | | --- | --- | | `(x: x) == (x: x)` | `false` | | `let f = x: x; in f == f` | `false` | | `{ a = 1; f = x: x; } == { a = 1; f = x: x; }` | `false` | A lambda never compares equal, not even to itself, and one lambda anywhere in an attrset makes the whole comparison false. So two aspects delivering the same *function* at one option still conflict, and no `==`-level rule can fix that — it needs identity carried alongside the value. Derivations are unaffected because Nix short-circuits their comparison on `outPath`, which is why the reported case is fully fixable here.
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.

Closes #572, closes #567
Summary
Three route application fixes in the fx pipeline:
#572 — Multiple aspects defining the same flake output class clobber each other.
wrapRouteModulesevaluated each source module independently throughnestWithAdaptArgs, producing separate config definitions. The flake submodule's freeformunspecifiedtype shallow-merged them with//, keeping only the last.#567 — Class forwarder with
eachbreaks when imported from a mutual provider. Forward routes likenix→homeManagerregistered after the HM battery routehomeManager→nixos. The consumer fired first and collected fromhomeManagerbefore the producer had written to it.Audit —
nestPlainhad the same shallow merge, freeform type was too permissive, and duplicate instantiate specs were silently dropped.Changes
route/wrap.nix: Combine all source modules into a singleevalModulescall for thenestWithAdaptArgspath. AlignnestPlainto also useevalModulesinstead ofrecursiveUpdate. IntroducemergeableType— a custom freeform type that deep-merges attrsets, concatenates lists, and errors on conflicting scalar/derivation values (matching NixOS module system semantics).route/apply.nix: AddtopoSortRoutes— partitions complex forward routes so producers (whoseintoClassfeeds another forward'sfromClass) fire before consumers.resolve.nix: Addlib.warnIfwhen multiple instantiate specs target the same output path on the same system.Test plan
flake-parts-modulestemplate passes (previously failed withrawfreeform type)just check-all(same results as main)