nix-daemon
A library for talking directly to the Nix Daemon.
Client Usage
To connect to a local nix-daemon, use a nix::DaemonStore (which implements the
Store trait):
use ;
let mut store = builder
.connect_unix
.await?;
let is_valid_path = store.is_valid_path.result.await?;
Server Usage
If you'd rather write your own nix-daemon compatible store, and expose it to existing
tools like nix-build, you can implement the Store trait yourself and use
nix::DaemonProtocolAdapter:
use UnixListener;
use ;
// Accept a connection.
let listener = bind?;
let = listener.accept.await?;
// This will just use `DaemonStore` to proxy to the normal daemon, but you can
// pass your own `Store` implementation here instead.
let mut store = builder
.connect_unix
.await?;
// Run the adapter!
let = conn.into_split;
let mut adapter = builder
.adopt
.await?;
See nix-supervisor for a more complex example.
Limitations
- Not all opcodes are implemented (yet). Part of this is because in order to test them, we need to find somewhere they're actually used.
- Only Nix 2.15+ and Lix is supported at the moment, but support for 2.3 is high on the todo list. (And fairly easy to add.)
Contributing
Please see the main README.
This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement NÂș 101069594.