NixOS logo

https://narinfo2json.edgecompute.app provides a service for querying information about nar packages hosted on the Nix binary cache, and getting responses in JSON format.

Heads up: This service is IN BETA, running on Fastly's Compute@Edge platform. Don't rely on it (yet!)

Usage

Nix binary packages downloaded from cache.nixos.org are identified by a hash, which are part of the name when you build them:

$ nix-build --no-out-link -QA hello
/nix/store/ylhzcjbchfihsrpsg0dxx9niwzp35y63-hello-2.10
$ HASH=$(nix-build --no-out-link -QA hello | cut -d'/' -f4 | cut -d'-' -f1)
$ echo "$HASH"
ylhzcjbchfihsrpsg0dxx9niwzp35y63

Given a hash like ylhzcjbchfihsrpsg0dxx9niwzp35y63 above, we can acquire a .narinfo file containing metadata about the built package:

$ curl "https://cache.nixos.org/${HASH}.narinfo"
StorePath: /nix/store/ylhzcjbchfihsrpsg0dxx9niwzp35y63-hello-2.10
URL: nar/1gj4adspvqmq09kcilx1b2dim8s7jdxrga69ca2dmjs1b8jw3fq7.nar.xz
...

.narinfo files like the one above are composed of simple Key: Value pairs that describe the build artifact. So given $HASH, if you want a JSON representation of the above, just change the domain name to narinfo2json.edgecompute.app and change the file extension to .json:

$ curl -s "https://narinfo2json.edgecompute.app/${HASH}.json" | jq
{
  "StorePath": "/nix/store/ylhzcjbchfihsrpsg0dxx9niwzp35y63-hello-2.10",
  "URL": "nar/1gj4adspvqmq09kcilx1b2dim8s7jdxrga69ca2dmjs1b8jw3fq7.nar.xz",
  ...
}

Limits and abuse

This service is "serverless" "edge" "application" and therefore it transforms narinfo files into JSON objects on-the-fly, every time you make an HTTP request. Those responses are cached to reduce latency and processing load further. Thus the only scaling limitation for usage should be... your imagination :)

Note: This service conveniently emits Cross-Origin Resource Sharing headers that allow other websites (such as the ones you write) to import its JSON data as a resource:

$ curl -is https://narinfo2json.edgecompute.app/nix-cache-info.json | \
    grep -iF access-control-allow-origin
access-control-allow-origin: *

This is considered an act of good will and good faith. On that note...

Usage of this service is monitored for anti-abuse purposes. Generally, I wouldn't worry about qualifying as "abuse" for most needs, even if you're automating your usage and making many requests — only the most truly absurd situations would demand a response. If you expect to be using this service in some kind of heavy capacity or for heavy load, please reach out to me (I'd like to know why.) If you don't even know what "heavy load" is (e.g. "Is 2 requests-per-second forever a heavy load?") feel free to reach out and ask anyway.


Help, troubleshooting, and about this service

This service is a experiment developed by Austin Seipp, a long-time NixOS developer and Fastly employee. (As usual with such matters, this system and should not be seen as any particular endorsement or statement on behalf of my employer.)

If you're having issues with this service, please reach out to me on GitHub or by email — aseipp at fastly dot com — and supply as much detail as possible.

General support for Nix and the Nix community can be found on the NixOS website. The source code for this service, landing page content, and automation details are available at this URL.


© Austin Seipp, 2020. Support NixOS! π
Content delivery provided by Fastly's Compute@Edge platform.
Psst... A new binary cache is coming — try it now!