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

pkg/store: init #86

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft

pkg/store: init #86

wants to merge 17 commits into from

Conversation

flokli
Copy link
Collaborator

@flokli flokli commented Jul 13, 2022

This provides a bunch of store-related components and concepts. Very WIP. PR opened for some early feedback.

  • A "Path Store", storing information about an output path (some .narinfo-style metadata, and the listing of .nar files)

  • A "Chunk Store", storing content-adressed chunks

  • Something converting from .narinfo and .nar to that format, plus tests.

  • I'm not yet sure about the package layout. pkg/nixpath feels a bit alien, and I'd probably like to have two packages, one for "path metadata and stores", and one for chunks (?)

  • There still needs to be a store exposing a "legacy" binary cache with these new interfaces (populating a "Path Store" and "Chunk Store" on access).

  • There still needs to be something converting back from these two stores to .nar and .narinfo

  • Once that's done, we probably want to write an HTTP handler, so nix copy to it, and nix-store -r from it becomes possible.

  • There needs to be more tests (for all chunk stores, for all path stores).

@flokli flokli mentioned this pull request Jul 13, 2022
@flokli
Copy link
Collaborator Author

flokli commented Jul 13, 2022

I was surprised that the SimpleChunker produced only one chunk. For some reason, I assumed it would output fixed-sized chunks (modulo the last one).

It is explained in the description though ;-) It's picking up one of the ideas from https://alternativebit.fr/posts/nixos/future-of-nix-substitution/, which hashes each file inside the .nar individually. It might make sense to not involve a complicated chunker if the file is not much bigger than a defined file size, so this might entirely get absorbed into the import logic. If not, we could probably give it a better name at least :-)

How useful is it to keep the offset with the chunk? Potentially it could be returned by the Next() function.
Or if each Chunk has a Size(), then a list of chunks is enough to re-compose the original file.

It wasn't really useful - adressed in ecf6906. Each chunk now is just an alias to []byte.

@flokli flokli force-pushed the store branch 2 times, most recently from cbf1958 to e3d65a0 Compare July 13, 2022 15:41
flokli and others added 17 commits July 19, 2022 20:55
This provides two different implementations to chunk data.
very WIP, and not sure about some of the interfaces yet.
Chunkers should immediately return io.EOF if an empty []byte is passed
to them. We don't want empty chunks to be legal.
This provides a way to hash bytes, and get back a go-multihash
identifier for it.
This provides a convenience writer, which can be used to verify hashes
and filesizes match some expectations.
Co-Authored-By: Jonas Chevalier <[email protected]>
…k}Entry

This allows using these later with a common interface.
This converts a PathInfo back to a .nar file.
Comment on lines +223 to +224
// This means, we render the NAR file twice - once to calculate NarHash, NarSize,
// a second time to do the actual upload.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe that's an argument for actually storing NarHash and NarSize in the PathInfo.

@adisbladis, what do you think?

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.

1 participant