Repository navigation
fix: don't force aspect content during key classification (#580) - #581
Merged
theutz merged 1 commit intoMay 31, 2026
Merged
Conversation
Classifying an unregistered aspect key as nested-or-content walked the
value with `builtins.isAttrs (val.${sk} or null)`, forcing every sub-value
to WHNF. Classification runs while the flake output set is assembled, so a
value reading the flake's own `self.outputs` (e.g.
`nixpkgs.overlays = builtins.attrValues self.outputs.overlays`) re-entered
the `self` fixpoint and threw "infinite recursion encountered". Registered
class keys bypass this path, so only unregistered keys cycled.
Detect nested aspects from recognized key names (class / pipe / structural
like `includes`) at the value's top level, forcing a sub-value only when its
name matches a registered class. Sub-aspects are never auto-walked — they
activate via explicit `includes` — so every nested aspect exposes a
recognized key at its own top level, making the value-forcing descent
unnecessary.
The forwarder and homeManager user in the original report were incidental;
neither is required to trigger the recursion.
theutz
approved these changes
May 31, 2026
theutz
enabled auto-merge (squash)
May 31, 2026 06:15
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 #580. Consuming a flake self-output from an unregistered aspect key threw
infinite recursion encountered:Worked in v0.16; regressed with the fx-pipeline rewrite (#475). Present on
main— independent of #575.Root cause
key-classification.nixdecided whether an unregistered key was a nested sub-aspect by descending through its value withbuiltins.isAttrs (val.${sk} or null), which forces every sub-value to WHNF. Classification runs while the flake output set is being assembled, so forcing a value that readsself.outputsre-enters the flakeselffixpoint (outputs = flake.outputs (inputs // { self = result; })) → infinite recursion.Registered class keys (
nixos/darwin/homeManager) bypass this path and stay lazy until NixOS-module build time (after theselffixpoint resolves), which is why only unregistered keys likenixpkgscycled.builtins.tryEvalcannot guard it — it does not catch infinite recursion.Fix
Detect nested aspects from recognized key names (class / pipe / structural like
includes) at the value's top level, forcing a sub-value only when its name matches a registered class — never under arbitrary content keys.This is sound because nested sub-aspects are never auto-walked (see
compile-static); they activate via explicitincludes, so every nested aspect exposes a recognized key at its own top level. The value-forcing descent was unnecessary.Notes on the original report
Verified empirically: the forwarder and the
homeManageruser were incidental — the minimal trigger is just an unregistered key readingself.outputs.*. Also confirmed this is not the stack-overflow addressed by #579 (distinct error class; the recursion persists with #579 merged).Validation
deadbugs/issue-580-self-output-classification-recursion.nix(repro + a registered-key boundary guard): infinite recursion → ✅ 2/2musjj/recursion-bug, full forwarder + homeManager +self.outputs.overlays): infinite recursion → evaluates