# Three ways to smuggle SQLite into Nix

> Hacker News story 49390286 · language: en · submitted 2026-08-21
> Web version: https://zeli.app/story/49390286
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 25 · by [domenkozar](<https://news.ycombinator.com/user?id=domenkozar>) · 💬 6
[original](<https://fzakaria.com/2026/08/19/three-ways-to-smuggle-sqlite-into-nix>) · [HN discussion](<https://news.ycombinator.com/item?id=49390286>)

## Summary

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.

## Key quote

> 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.

## HN discussion (6 comments)

### [Naru41](<https://news.ycombinator.com/item?id=49395546>)

> Just convert it to a binary data structure suitable for this purpose and use the old-fashioned bsearch. It's so simple that you wouldn't even need SQLite.

### [kevincox](<https://news.ycombinator.com/item?id=49392359>)

> It seems that you could just compile the data into the WASM blob. Then use a more optimized query engine than sqlite. This should be very fast to compile (most of the WASM is just a byte buffer, the code is just a few binary searches and some result encoding). The downside is that you need to recompile to update the repo, but I don't think that should be particularly expensive.

### [setheron](<https://news.ycombinator.com/item?id=49395281>)

> (author)
>
> If you have questions, happy to try and answer some.

---

## Cite

- Page: https://zeli.app/story/49390286
- Date: 2026-08-21
- Source: fzakaria.com (https://fzakaria.com/2026/08/19/three-ways-to-smuggle-sqlite-into-nix)
- Hacker News: https://news.ycombinator.com/item?id=49390286

## Other languages

- zh: https://zeli.app/zh/story/49390286 · markdown: https://zeli.app/zh/story/49390286.md
- ja: https://zeli.app/ja/story/49390286 · markdown: https://zeli.app/ja/story/49390286.md
- ko: https://zeli.app/ko/story/49390286 · markdown: https://zeli.app/ko/story/49390286.md
- de: https://zeli.app/de/story/49390286 · markdown: https://zeli.app/de/story/49390286.md
- es: https://zeli.app/es/story/49390286 · markdown: https://zeli.app/es/story/49390286.md
