HeadlinesBriefing favicon HeadlinesBriefing.com

Three Ways to Smuggle SQLite into Nix

Hacker News •
×

The nixpkgs-multiverse project uses JSON indexes (versions.json at 5.3 MiB, history.json at 7.5 MiB) covering 305,492 package versions across 31,904 packages. Nix's builtins.fromJSON eagerly parses entire files, making single lookups cost as much as full scans.

Three workarounds exist. builtins.exec (since 2017) runs SQLite and parses its Nix-formatted output, but spawns a process per query. builtins.importNative (since 2014) loads a shared library with cached SQLite handles, avoiding startup overhead. Both require allow-unsafe-native-code-during-evaluation.

A third approach converts the index to a 6.0 MiB Nix file, leveraging Nix's lazy evaluation to touch only needed attributes. A fourth option, builtins.wasm (March 2026), calls WebAssembly functions, extending Nix without new builtins.