Skip to content

fix: refuse a follows cycle among overrides by name instead of overflowing the stack - #38

Merged
vic merged 1 commit into
mainfrom
fix/follows-cycle
Oct 29, 2026
Merged

vic merged 1 commit into
mainfrom
fix/follows-cycle

Conversation

@sini

@sini sini commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #35. In mkDefaultWithInputsInput, recFollows walks follows chains among the overrides. When two overrides follow each other and neither chain reaches the input being built, the walk never ends:

{ nixpkgs3.follows = "common-dep/x"; common-dep.follows = "nixpkgs3/y"; … }
# error: stack overflow (possible infinite recursion)

The walk now carries the inputs already on its chain. When it meets one of them again it throws by name:

error: with-inputs: follows cycle: common-dep -> nixpkgs3 -> common-dep

Chains that reach the input, or that stop at a root that isn't an override (#35), behave as before.

Validation

  • nix-unit ./tests.nix: 55/55, including the new input-overrides.test-follows-cycle-is-refused, which expects a ThrownError matching follows cycle.
  • With with-inputs.nix reverted, the suite fails with stack overflow (possible infinite recursion), so the test catches the bug.
  • treefmt --ci: 0 files changed.
  • Not run: just loaders.

…owing the stack

Two overrides that follow each other, with neither chain reaching the
input being built, made recFollows recurse until the stack overflowed.
The walk now carries the inputs already on its chain and throws
"with-inputs: follows cycle: a -> b -> a". Reported in Matrix.
@vic
vic merged commit 852fb6e into main Oct 29, 2026
1 check passed
@vic
vic deleted the fix/follows-cycle branch October 29, 2026 16:26
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.

2 participants