Announcing nar-serve - Unpack and serve NAR file content on the fly

In a setting where your CI is pushing to your nix binary cache, have you ever noticed that build artifacts usually have to be pushed a second time? What if it wasn’t necessary? nar-serve is a HTTP service that you can put in front of your cache and serve the content of the NAR files directly.

Use cases

  • Avoid publishing build artifacts to both the binary cache and another service.
  • Allows to share build results easily.
  • Inspect the content of a NAR file.

Demo

https://nar-serve.zimbatm.now.sh/ is a demo deployment that connects to https://cache.nixos.org/ . It’s freely available but I don’t make any guarantees in terms of availability :wink:

Append any store path to the hostname to fetch and unpack it on the fly. That’s it.

Eg:

Contact

If that’s something you would be interested in deploying in your company, please contact me.

The source code is all freely available at https://github.com/zimbatm/nar-serve and I am available to develop extensions for it.

3 Likes

You may want to setup a robots.txt (as I may need), otherwise it’s possible that you could unexpectedly serve results.

Just like one of my (on pause) experiment does.

Thanks! https://nar-serve.zimbatm.now.sh/robots.txt added.

I like your idea of generating HTML for manpages on the fly.

Depending on the level of interest I want to expand the service to include more overlays like that. For example adding the docker registry API to serve images built with dockerTools.buildImage. Or a naming service that aliases a store path to a hostname for static websites. It really depends on what people are asking for or what I need.

1 Like

From the #nixos-officehours discussion:

Another use-case would be to be able to publish the manuals directly from the binary cache. This would allow us to have all versions of the manual available instead of just the latest one. For this, the service ideally needs to have a name to store profile mapping capability added.