Skip to content

Fix deep overrides#108

Merged
edolstra merged 4 commits intodetsys-mainfrom
fix-deep-overrides
Jun 25, 2025
Merged

Fix deep overrides#108
edolstra merged 4 commits intodetsys-mainfrom
fix-deep-overrides

Conversation

@edolstra
Copy link
Collaborator

Motivation

An override like

inputs.foo.inputs.bar.inputs.nixpkgs.follows = "nixpkgs";

implicitly set inputs.foo.inputs.bar to flake:bar, which led to an unexpected error like

error: cannot find flake 'flake:bar' in the flake registries

We now no longer create a parent override (like for foo.bar in the example above) if it doesn't set an explicit ref or follows attribute. We only recursively apply its child overrides.

Fixes NixOS#8325, #95, NixOS#12083, NixOS#5790. Based in part on NixOS#6621 by @Kha.

Also, we now disallow having both a flakeref and a follows attribute on an input, since it doesn't make sense to have both.

Context

edolstra and others added 3 commits June 12, 2025 20:32
An override like

  inputs.foo.inputs.bar.inputs.nixpkgs.follows = "nixpkgs";

implicitly set `inputs.foo.inputs.bar` to `flake:bar`, which led to an
unexpected error like

  error: cannot find flake 'flake:bar' in the flake registries

We now no longer create a parent override (like for `foo.bar` in the
example above) if it doesn't set an explicit ref or follows
attribute. We only recursively apply its child overrides.

Fixes NixOS#8325, #95, NixOS#12083, NixOS#5790.
Taken from NixOS#6621.

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
Having both doesn't make sense so it's best to disallow it. If this
causes issues we could turn into a warning.
@github-actions
Copy link

@github-actions github-actions bot temporarily deployed to pull request June 12, 2025 18:53 Inactive
OverrideTarget {
.input = inputOverride,
.sourcePath = sourcePath,
.parentInputAttrPath = inputAttrPathPrefix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be changed to prefix like line 472 above was?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct because it's the input attr path used to resolve relative path inputs. In an override, these should refer to the attr path of the overriding flake, which is inputAttrPathPrefix.

@edolstra edolstra requested a review from cole-h June 25, 2025 16:44
@edolstra edolstra enabled auto-merge June 25, 2025 16:58
@edolstra edolstra added this pull request to the merge queue Jun 25, 2025
Merged via the queue into detsys-main with commit 7bb167d Jun 25, 2025
32 checks passed
@edolstra edolstra deleted the fix-deep-overrides branch June 25, 2025 20:31
@edolstra edolstra mentioned this pull request Jun 26, 2025
2 tasks
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.

Allow overriding the follows of a transitive input without overriding its flakeref

2 participants