fetchToStore(): Avoid duplicate copying if the input is already a store path
Motivation
This is needed for the path:// input scheme (until it returns a FSInputAccessor to the original path, but that's blocked by #10089) and the Mercurial input scheme.
Note: it would be cleaner to have fetchToStore() as an overridable method on InputAccessor (as was originally the case), but the latter got moved to libutil so we can't do that anymore.
Context
Priorities and Process
Add :+1: to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.
Do we need isStorePath? I don't think so
We do need that to ensure it's only used for store paths where we know their ingestion method.
As mentioned above, the architecturally cleaner way is to make fetchToStore() a method in InputAccessor (which is pretty much why that class exists in the first place), but it would require moving InputAccessor back to libfetcher. Which would be a much bigger change.
I think I rather solve this in a different way:
-
SourceAccessorhas optional content address (on the FSO level, so(FileIngestionMethod, Hash)pair) -
fetchToStorecan use that to construct a store path and see if it is in the store - only add to store if it isn't.
I am still hoping InputAccessor can go away entirely.
If you could take a stab at https://github.com/NixOS/nix/pull/10467#pullrequestreview-2001462789 @edolstra, I would be happy to take on this one per my plan above.