Nix Observability Daemon
observability
nix
1## nod
2
3A simple daemon that collects Nix build and substitution statistics using structured JSON logs.
4
5## requirements
6
7- Nix 2.30 or later (`json-log-path` support)
8
9## building
10
11```bash
12cargo build --release
13```
14
15## usage
16
17Start the daemon:
18
19```bash
20nod daemon
21```
22
23Point Nix at the socket in `nix.conf`:
24
25```
26json-log-path = /run/user/1000/nod/nod.sock
27```
28
29Then use Nix normally. View accumulated stats with:
30
31```bash
32nod stats # all time
33nod stats -d 7 # last 7 days
34nod stats -m 3 # last 3 months
35nod stats -y 1 # last year
36nod clean # reset the database
37```
38
39## configuration
40
41| flag | env | default |
42|------|-----|---------|
43| `--socket` | `NOD_SOCKET` | `$XDG_RUNTIME_DIR/nod/nod.sock` |
44| `--db` | `NOD_DB` | `$XDG_DATA_HOME/nod/nod.db` |
45
46Both directories are created automatically. The socket path in `nix.conf` must match `--socket`.
47
48## how?
49
50Nix 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.
51
52Relevant Nix source: [logging.hh](https://github.com/NixOS/nix/blob/b4de973847370204cf28fe2092abdd21f25ee0e8/src/libutil/include/nix/util/logging.hh)