snix/snix/store
Starnick4444 2a1cd31d52 chore: finish migration to 2024 edition
Closes #114
Removes the per-crate rustfmt configs, sets default edition to 2024.
This should fix the formatting issues between some editors and CI.

Change-Id: I9bb3a5f49f8ba2c8a616f29e87b7f8093187a165
Reviewed-on: https://cl.snix.dev/c/snix/+/30595
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-08-03 20:10:05 +00:00
..
protos refactor(snix/castore): rename proto node to entry 2025-04-04 23:19:07 +00:00
src fix(snix/castore): allow result_large_err for redb create_schema 2025-07-31 15:44:56 +00:00
build.rs chore(snix): s/tvix/snix/ 2025-03-17 17:15:08 +00:00
Cargo.toml refactor(snix/clippy): stop allowing blocks_in_conditions 2025-07-29 10:19:46 +00:00
default.nix chore(snix): s/tvix/snix/ 2025-03-17 17:15:08 +00:00
README.md chore(snix): s/tvix/snix/ 2025-03-17 17:15:08 +00:00

//snix/store

This contains the code hosting the snix-store.

For the local store, Nix realizes files on the filesystem in /nix/store (and maintains some metadata in a SQLite database). For "remote stores", it communicates this metadata in NAR (Nix ARchive) and NARInfo format.

Compared to the Nix model, snix-store stores data on a much more granular level than that, which provides more deduplication possibilities, and more granular copying.

However, enough information is preserved to still be able to render NAR and NARInfo when needed.

More Information

The store consists out of two different gRPC services, snix.castore.v1 for the low-level content-addressed bits, and snix.store.v1 for the Nix and StorePath-specific bits.

Check the protos/ subfolder both here and in castore for the definition of the exact RPC methods and messages.

Interacting with the GRPC service manually

The shell environment in //snix provides evans, which is an interactive REPL-based gPRC client.

You can use it to connect to a snix-store and call the various RPC methods.

$ cargo run -- daemon &
$ evans --host localhost --port 8000 -r repl
  ______
 |  ____|
 | |__    __   __   __ _   _ __    ___
 |  __|   \ \ / /  / _. | | '_ \  / __|
 | |____   \ V /  | (_| | | | | | \__ \
 |______|   \_/    \__,_| |_| |_| |___/

 more expressive universal gRPC client


localhost:8000> package snix.castore.v1
snix.castore.v1@localhost:8000> service BlobService

snix.castore.v1.BlobService@localhost:8000> call Put --bytes-from-file
data (TYPE_BYTES) => /run/current-system/system
{
  "digest": "KOM3/IHEx7YfInAnlJpAElYezq0Sxn9fRz7xuClwNfA="
}

snix.castore.v1.BlobService@localhost:8000> call Read --bytes-as-base64
digest (TYPE_BYTES) => KOM3/IHEx7YfInAnlJpAElYezq0Sxn9fRz7xuClwNfA=
{
  "data": "eDg2XzY0LWxpbnV4"
}

$ echo eDg2XzY0LWxpbnV4 | base64 -d
x86_64-linux

Thanks to snix-store providing gRPC Server Reflection (with reflection feature), you don't need to point evans to the .proto files.