nix icon indicating copy to clipboard operation
nix copied to clipboard

fetchToStore(): Avoid duplicate copying if the input is already a store path

Open edolstra opened this issue 1 year ago • 3 comments

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.

edolstra avatar Apr 15 '24 16:04 edolstra

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.

edolstra avatar Apr 15 '24 17:04 edolstra

I think I rather solve this in a different way:

  1. SourceAccessor has optional content address (on the FSO level, so (FileIngestionMethod, Hash) pair)
  2. fetchToStore can use that to construct a store path and see if it is in the store
  3. only add to store if it isn't.

I am still hoping InputAccessor can go away entirely.

Ericson2314 avatar Apr 15 '24 18:04 Ericson2314

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.

Ericson2314 avatar Apr 15 '24 19:04 Ericson2314