New tool for exploring nar contents online

I wrote some javascript code to follow a .narinfo URL field, compiled xz-embedded for web assembly, and wrote some more code to parse a .nar file. With all that, you can explore the contents of .nar files from a binary cache (assuming suitable CORS) from inside a browser.

The tool (not intended to be a permanent deployment):

https://trusted-friendly-sesame.glitch.me/nix-cache.html

For example, for this build Hydra - Build 189501777 of job nixos:release-22.05:nixpkgs.nix.x86_64-linux, click the “Help” button on one of the build products to see:

$ nix-env -i /nix/store/7ghhnlwla2mddkg7hgqa5v0sr8g5hga8-nix-2.8.1 --option binary-caches https://cache.nixos.org

Enter that https://cache.nixos.org/ (add trailing slash) in the “cache base” field and the hash part of the path 7ghhnlwla2mddkg7hgqa5v0sr8g5hga8 in the “hash” field. (These particular values are pre-populated to make it easy for people to try out the tool.) Then click “view nar.”

Then you get a blank screen for a while, as it downloads the .nar.xz into memory, decompresses it, and parses it. Check the F12 developer console to see if things are working during this time. After that finishes, you get an expandable tree sort of thing that lets you explore the directories and files within. You can additionally click a file’s “create object url” button and then right click the “contents” link that appears to save a copy of that specific file.


I use the Nix package manager in some application-specific containers and I don’t have nix or nixos on my local computer, so it’s a little more of a hassle if I ever need to look at what’s in a package that I don’t have installed somewhere.

Inspiration comes from Debian having an online package search that can display the list of files in a package, e.g. Debian -- File list of package nix-bin/bullseye/amd64

5 Likes

Is the source code up somewhere?

1 Like

yeah, you’re all welcome to use the browser’s view source. mostly view the misc.js file. I have this on Glitch, where you can use their online code editor to view the source too

I haven’t set up a license file, but everyone please have it under the MIT license and xz-embedded under the license of its own COPYING file.

It would be cool if you could throw that into a git repository somewhere.

sure would, good idea! I’ll be getting to that in a few days

thusly thrown! coming up, I’ll be filing some issues in that repo to plan out future work

bonus content: I’m writing up the process of building this:

4 Likes