nod#
A simple daemon that collects Nix build and substitution statistics using structured JSON logs.
requirements#
- Nix 2.30 or later (
json-log-pathsupport)
building#
cargo build --release
usage#
Start the daemon:
nod daemon
Point Nix at the socket in nix.conf:
json-log-path = /run/user/1000/nod/nod.sock
Then use Nix normally. View accumulated stats with:
nod stats # all time
nod stats -d 7 # last 7 days
nod stats -m 3 # last 3 months
nod stats -y 1 # last year
nod clean # reset the database
configuration#
| flag | env | default |
|---|---|---|
--socket |
NOD_SOCKET |
$XDG_RUNTIME_DIR/nod/nod.sock |
--db |
NOD_DB |
$XDG_DATA_HOME/nod/nod.db |
Both directories are created automatically. The socket path in nix.conf must match --socket.
how?#
Nix 2.30 added json-log-path, which writes a stream of structured activity events (start/result/stop) to a file or Unix socket while a build runs. nod listens on that socket, tracks in-flight activities by ID, and on each stop event inserts a completed row into a local SQLite database. nod stats queries that database through the daemon.
Relevant Nix source: logging.hh