Skip to content

Use correct parent outPath for relative path inputs #13170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2025

Conversation

MattSturgeon
Copy link
Contributor

@MattSturgeon MattSturgeon commented May 12, 2025

Motivation

Ensure relative path inputs are relative to the parent node's actual outPath, instead of the subtly different sourceInfo.outPath.

Without this, nested relative-path inputs within the same repo end up repeating the parent's relative path segment:

trace:
subdir for root:
flakeDir for root:
(no parent)
outPath for root: /nix/store/s4j8hchzds1x57hirv8y7p19nl44kqwr-source
sourceInfo.outPath for root: /nix/store/s4j8hchzds1x57hirv8y7p19nl44kqwr-source

trace:
subdir for nestedFlake1:
flakeDir for nestedFlake1: /./nested-flake1
parentNode.flakeDir for nestedFlake1:
outPath for nestedFlake1: /nix/store/s4j8hchzds1x57hirv8y7p19nl44kqwr-source//./nested-flake1
sourceInfo.outPath for nestedFlake1: /nix/store/s4j8hchzds1x57hirv8y7p19nl44kqwr-source//./nested-flake1

trace:
subdir for nestedFlake2:
flakeDir for nestedFlake2: /./nested-flake1/./nested-flake2
parentNode.flakeDir for nestedFlake2: /./nested-flake1
outPath for nestedFlake2: /nix/store/s4j8hchzds1x57hirv8y7p19nl44kqwr-source//./nested-flake1//./nested-flake1/./nested-flake2
sourceInfo.outPath for nestedFlake2: /nix/store/s4j8hchzds1x57hirv8y7p19nl44kqwr-source//./nested-flake1//./nested-flake1/./nested-flake2

Notice how nestedFlake2 has /./nested-flake1//./nested-flake1/., repeating nestedFlake1's path.

Context

cc @edolstra @roberth @packruler @meskill

Testing

I assume a test case would be beneficial, however I'm not familiar with your test suite. Feel free to take over this PR or cherry-pick the changes into a new PR if that is easier. Or if you have ideas for tests, I can try to implement them with some hand-holding 😀


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@MattSturgeon MattSturgeon requested a review from edolstra as a code owner May 12, 2025 11:28
@Mic92 Mic92 requested a review from roberth May 14, 2025 17:22
@Mic92 Mic92 added this to Nix team May 14, 2025
@Mic92 Mic92 moved this to To triage in Nix team May 14, 2025
@roberth roberth self-assigned this May 14, 2025
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label May 14, 2025
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2025-05-14-nix-team-meeting-minutes-226/64298/1

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

This does look more correct!

MattSturgeon and others added 3 commits May 18, 2025 00:38
Ensure relative path inputs are relative to the parent node's _actual_
`outPath`, instead of the subtly different `sourceInfo.outPath`.

Additionally, non-flake inputs now also have a `sourceInfo` attribute.

This fixes the relationship between `self.outPath` and
`self.sourceInfo.outPath` in some edge cases.

Fixes NixOS#13164
@MattSturgeon MattSturgeon force-pushed the fix/call-flake/rel-path branch from 9f4e7ce to 2922e30 Compare May 17, 2025 23:45
@roberth roberth merged commit f18af84 into NixOS:master May 19, 2025
12 checks passed
@roberth
Copy link
Member

roberth commented May 19, 2025

Thank you @MattSturgeon!

@MattSturgeon MattSturgeon deleted the fix/call-flake/rel-path branch May 19, 2025 12:34
MattSturgeon added a commit to MattSturgeon/flake-compat that referenced this pull request May 19, 2025
Ensure relative path inputs are relative to the parent node's _actual_
`outPath`, instead of the subtly different `sourceInfo.outPath`.

Additionally, non-flake inputs now also have a `sourceInfo` attribute.

This fixes the relationship between `self.outPath` and
`self.sourceInfo.outPath` in some edge cases.

(cherry picked from commit NixOS/nix@46beb9a)
(cherry picked from PR NixOS/nix#13170)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Nested flake source paths broken
3 participants