The Nix daemon uses a custom binary protocol — the nix daemon protocol — to communicate with just about everything. When you run nix build on your

Re-implementing the Nix protocol in Rust - Tweag

submited by
Style Pass
2024-04-25 10:00:03

The Nix daemon uses a custom binary protocol — the nix daemon protocol — to communicate with just about everything. When you run nix build on your machine, the Nix binary opens up a Unix socket to the Nix daemon and talks to it using the Nix protocol1. When you administer a Nix server remotely using nix build --store ssh-ng://example.com [...], the Nix binary opens up an SSH connection to a remote machine and tunnels the Nix protocol over SSH. When you use remote builders to speed up your Nix builds, the local and remote Nix daemons speak the Nix protocol to one another.

Despite its importance in the Nix world, the Nix protocol has no specification or reference documentation. Besides the original implementation in the Nix project itself, the hnix-store project contains a re-implementation of the client end of the protocol. The gorgon project contains a partial re-implementation of the protocol in Rust, but we didn’t know about it when we started. We do not know of any other implementations. (The Tvix project created its own gRPC-based protocol instead of re-implementing a Nix-compatible one.)

So we re-implemented the Nix protocol, in Rust. We started it mainly as a learning exercise, but we’re hoping to do some useful things along the way:

Leave a Comment