Skip to content
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

Try to substitute tree for all uses of fetchTree instead of just in flakes #3520

Closed
wants to merge 1 commit into from

Conversation

mkenigs
Copy link
Contributor

@mkenigs mkenigs commented Apr 20, 2020

Trying to fix the FIXME in fetchTree.cc:86

Wasn't quite sure how having a nar hash interacts with resolved refs. Since narHash is optional, a resolved ref could be immutable, but then possibly not locked? But then it doesn't make sense to assume that fetchOrSubstituteTree returns a lockedRef:

auto [sourceInfo, resolvedRef, lockedRef] = fetchOrSubstituteTree(

Should that be treated as an immutable ref but not locked? Or should substitute only occur for locked refs?

if (narHash) {
try {
auto tree = substituteTree(store);
return {std::move(tree), shared_from_this()};
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, this is not correct because this will return a different Tree and Input than fetchTreeInternal(). For instance, for a Git input, fetchTreeInternal() will return an Input that has rev set, and a Tree that has revCount and lastModified set.

So we can only substitute the store path if we can get those Input / Tree attributes in some other way. It works for flake inputs because flake.lock provides the missing attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok makes sense. So basically a locked ref always needs to be returned? Not that you couldn't substitute an unlocked ref with a narHash, but that wouldn't allow things like lockfile creation? If so was wondering why LockedRef isn't a subclass, which fetchTree could then return.

edolstra added a commit that referenced this pull request May 29, 2020
@edolstra edolstra closed this May 29, 2020
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.

None yet

2 participants