<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb" -->

---
title: A Nix store is three functions | daily.dev
description: A Nix binary cache only needs to implement three HTTP endpoints: nix-cache-info, a narinfo lookup, and a URL that serves the compressed archive. Because Nix...
canonical: https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: A Nix store is three functions | daily.dev
og:description: A Nix binary cache only needs to implement three HTTP endpoints: nix-cache-info, a narinfo lookup, and a URL that serves the compressed archive. Because Nix...
og:url: https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb
og:image: https://api.daily.dev/og/posts/6gA9iJJfb.png
og:image:alt: A Nix store is three functions
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# A Nix store is three functions

**[Farid Zakaria’s Blog](https://daily.dev/sources/fzakaria)** · 6 min read · 5 upvotes · 0 comments

## Summary

A Nix binary cache only needs to implement three HTTP endpoints: nix-cache-info, a narinfo lookup, and a URL that serves the compressed archive. Because Nix verifies packages via NarHash rather than trusting the transport, any static file host can act as a substituter, including GitHub Pages, GitHub Releases (via tomberek's github-store), git object databases (gachix), DNS TXT records, pastebins, OCI registries, and even video encodings uploaded to YouTube. The post walks through publishing a full Nix closure (a patched 'hello' package) as an actual npm package, then fetching and running it with nix copy and bwrap, showing npm dist-tags can mimic Nixpkgs channel semantics, while noting npm's lack of incremental publishing as a major inefficiency.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://fzakaria.com/2026/09/11/a-nix-store-is-three-functions>

## Questions this post answers

### What are the three HTTP endpoints a server must implement to act as a Nix binary cache?

A Nix binary cache needs only three endpoints: a GET for nix-cache-info returning the StoreDir (e.g. /nix/store), a GET for a 32-character store hash plus .narinfo returning metadata about an archive, and a GET for the URL named in that narinfo's URL field returning the compressed archive itself. Any static file server that can answer these three requests works as a remote Nix store, regardless of protocol.

_daily.dev surfaces deep dives like this for developers designing or debugging custom Nix substituters._

### Why can Nix packages be fetched from an untrusted third-party binary cache without breaking signature verification?

Because a narinfo's Sig field only covers StorePath, NarHash, NarSize, and References, not URL, FileHash, FileSize, or Compression. Nix decompresses the fetched archive and checks that its NarHash matches the signed value, so the transport and the intermediary hosting it need not be trusted at all, only the final decompressed content.

_understanding this trust model on daily.dev helps when evaluating alternative or mirrored Nix caches._

### Can you publish a Nix package closure to the npm registry and install it with Nix?

Yes: since nix copy --to file:// emits a directory structure and npm publishes directories, a full closure (narinfos, nar.xz archives, and nix-cache-info) can be packaged with a package.json and pushed via npm publish. Nix can then fetch it directly with nix copy --from https://unpkg.com/<package>@latest/, using --trusted-public-keys to verify the signature, and run the result with bwrap.

_daily.dev helps developers exploring unconventional package distribution tricks like repurposing npm for Nix._

## Similar posts on daily.dev

- [Any Nix package, live in your browser](https://daily.dev/posts/any-nix-package-live-in-your-browser-w1ybvii2l) · Farid Zakaria’s Blog · 2 upvotes · 0 comments
- [One store, two frontends](https://daily.dev/posts/one-store-two-frontends-envwksejx) · Farid Zakaria’s Blog · 1 upvotes · 0 comments
- [Native Nix Support in Artifactory: The Binary Cache for the Enterprise](https://daily.dev/posts/native-nix-support-in-artifactory-the-binary-cache-for-the-enterprise-ynzqinftu) · JFrog · 0 upvotes · 0 comments
- [A Nix terminology primer by a newcomer](https://daily.dev/posts/a-nix-terminology-primer-by-a-newcomer-f4fgvndsi) · Lobsters · 0 upvotes · 0 comments
- [Visualizing Nix closures](https://daily.dev/posts/visualizing-nix-closures-kree8ah8c) · Farid Zakaria’s Blog · 2 upvotes · 0 comments

---

Tags: [#npm](https://daily.dev/tags/npm), [#nixos](https://daily.dev/tags/nixos)

[View this post on daily.dev](https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"A Nix store is three functions","url":"https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb"},"datePublished":"2026-09-12T05:47:06.827Z","dateModified":"2026-09-12T05:47:34.644Z","description":"A Nix binary cache only needs to implement three HTTP endpoints: nix-cache-info, a narinfo lookup, and a URL that serves the compressed archive. Because Nix...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/73663cbbde2ecbb106705498916772cc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/73663cbbde2ecbb106705498916772cc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Farid Zakaria’s Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Farid Zakaria’s Blog","logo":"https://media.daily.dev/image/upload/s--YqqvRt90--/f_auto/v1723789280/logos/fzakaria","url":"https://daily.dev/sources/fzakaria"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"npm,nixos","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Farid Zakaria’s Blog","item":"https://daily.dev/sources/fzakaria"},{"@type":"ListItem","position":3,"name":"A Nix store is three functions"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/a-nix-store-is-three-functions-6ga9ijjfb#faq","mainEntity":[{"@type":"Question","name":"What are the three HTTP endpoints a server must implement to act as a Nix binary cache?","acceptedAnswer":{"@type":"Answer","text":"A Nix binary cache needs only three endpoints: a GET for nix-cache-info returning the StoreDir (e.g. /nix/store), a GET for a 32-character store hash plus .narinfo returning metadata about an archive, and a GET for the URL named in that narinfo's URL field returning the compressed archive itself. Any static file server that can answer these three requests works as a remote Nix store, regardless of protocol. daily.dev surfaces deep dives like this for developers designing or debugging custom Nix substituters."}},{"@type":"Question","name":"Why can Nix packages be fetched from an untrusted third-party binary cache without breaking signature verification?","acceptedAnswer":{"@type":"Answer","text":"Because a narinfo's Sig field only covers StorePath, NarHash, NarSize, and References, not URL, FileHash, FileSize, or Compression. Nix decompresses the fetched archive and checks that its NarHash matches the signed value, so the transport and the intermediary hosting it need not be trusted at all, only the final decompressed content. understanding this trust model on daily.dev helps when evaluating alternative or mirrored Nix caches."}},{"@type":"Question","name":"Can you publish a Nix package closure to the npm registry and install it with Nix?","acceptedAnswer":{"@type":"Answer","text":"Yes: since nix copy --to file:// emits a directory structure and npm publishes directories, a full closure (narinfos, nar.xz archives, and nix-cache-info) can be packaged with a package.json and pushed via npm publish. Nix can then fetch it directly with nix copy --from https://unpkg.com/\u003cpackage\u003e@latest/, using --trusted-public-keys to verify the signature, and run the result with bwrap. daily.dev helps developers exploring unconventional package distribution tricks like repurposing npm for Nix."}}]}
```

