Repository navigation
fix: nested sub-aspects doubled when included and missed by guard hasAspect - #693
Merged
Merged
Conversation
…des` Since #671 a nested aspect publishes `provides` and `_` as the same value. wrapperToAspect handed both to aspectSubmodule, whose `_` alias counted the read view as a second `provides` definition, so a nested aspect reached through `includes` delivered every provides leaf twice. Drop the functor-bearing `_` before the submodule merge. #692
A nested sub-aspect reference (`den.aspects.foo.bar`) reaches a `policy.when` guard as a content wrapper carrying only `__aspectChain`. The guard keyed it with identity.key, which names it `<anon>`, so `host.hasAspect den.aspects.foo.bar` was false even when bar was present and the guarded include was silently dropped. The same aspect declared under `provides.` carries a name and matched. Key a name-less ref by its chain, as the entity-surface hasAspect already does.
_ out of its re-merged provideshasAspect
Collaborator
Author
|
Vipul Tyagi on matrix was able to test and confirm the proves the fix worked for them |
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.
Fixes two defects where a nested sub-aspect (
den.aspects.foo.bar) behaves differently from the same aspect declared underprovides..includesdelivers itsprovidescontent twice.policy.whenguard'shost.hasAspectnever matches a nested sub-aspect.Summary
A nested aspect's
providesdoubled when it is included (#692)foo.includes = [ den.aspects.foo.bar ]withfoo.bar.provides.to-users.homeManagerdeclaring an option, home-manager fails withThe option `home-manager.users.tux.nested-marker' … is already declared in `homeManager@foo/bar/to-users'. The same aspect at the root (den.aspects.foo.provides.to-users) is unaffected.wrapperToAspect, innix/lib/aspects/types.nix. Since fix: aspect provenance collisions and the nested_alias (#670) #671 a nested aspect publishesprovidesand_as one value, so either spelling reads the same children. When the aspect is included,wrapperToAspecthands that value toaspectSubmodule. The submodule'smkAliasOptionModule [ "_" ] [ "provides" ]takes the published_as a second definition ofprovides, and every provides leaf ends up with two definitions. The declaredfoo.bar.provides.to-users.homeManageris a single raw lambda; the copy infoo.includescarried two__contentValues.wrapperToAspectnow drops_when it carries__functor. That marks the published read view rather than something the author wrote; a written_has already been folded intoprovidesbyfoldUnderscoreIntoProvides, whose comment states the same rule: a_read back off a wrapper "must stay out of provides". Nothing is lost, because the submodule builds its own_fromprovides.A guard's
hasAspectmisses a nested sub-aspecthost.hasAspect den.aspects.feature.host-part. Withhost-partdeclared underprovides.the guard passes; withhost-partas a plain nested key it fails and the user half is dropped silently, even thoughhost-partdoes reach the host (its content is in the output either way).__aspectChain = [ "feature" "host-part" ]and nonameormeta. The guard-time lookup inmkPipelineHasAspect(nix/lib/aspects/fx/handlers/compile-conditional.nix) keyed it withidentity.key, which names it<anon>. The path set does recordfeature/host-part, so the lookup always missed. Aprovides.child carries anameand keyed correctly.hasAspectchecks now key a reference that has__aspectChainand nonameby its chain, and everything else byidentity.keyas before. The entity-surfacehasAspect(has-aspect.nixrefKey) already handles this shape; it isn't reused because it requiresnameandmetatogether, and guard references like{ name = "dep-a"; }infx-compile-conditionalrely onidentity.keyacceptingnamealone.Tests
issue-692-nested-provides-to-users-twice: the reporter's two cases, with the root-levelprovides.to-usersas the control.nested-ref-guard-hasaspect: the Matrix reporter's shape, nested andprovides.forms, each with a mutual case and a host-opted-out case.Validation
_alias (#670) #671) and every commit after it through 4d69112.test-nested-provides-to-usersfails at 4d69112, and onlytest-nested-mutualfails innested-ref-guard-hasaspectwithout the guard change. With thetypes.nixfix, the included copy'sprovides.to-users.homeManagerdefinition count goes from 2 to 1.nix develop -c just cion the combined branch: 1250/1250, exit 0.nix develop -c just fmt: 0 files changed.