Three ways to smuggle SQLite into Nix

Three ways to smuggle SQLite into Nix

Nix's builtins.fromJSON eagerly parses entire JSON files, making large indexes costly. The author explores three workarounds to use SQLite for efficient queries: builtins.exec (running sqlite3 and parsing output), builtins.importNative (loading a C++ shared object), and a giant Nix file (leveraging laziness). A fourth option, builtins.wasm, is also discussed, with a custom read_file_range patch enabling SQLite's wasm build to read databases.

The whole point: the database handle outlives a single query, so the b-tree pages we touch stay warm for the rest of the evaluation.

More from this day

2026-08-21