edolstra / nix-serve

A standalone Nix binary cache server
GNU Lesser General Public License v2.1
163 stars 37 forks source link

Add docker setup #15

Open DanielFabian opened 4 years ago

DanielFabian commented 4 years ago

Hello,

I'm trying to figure out if there's a docker image with this. My background being, that I'm considering to set up a binary cache and because it would be an internal project, I don't want to use cachix. From what I gather, it should be fairly straight-forward to set up and I'm happy to do the work if it doesn't exist yet.

Could you please provide me with some guidance how to go about it in the most fruitful way?

From what I gather, there is no real nixos docker base image, correct? So the steps I see necessary, it would be:

A bit of help would be appreciated.

lheckemann commented 4 years ago

You can build a docker image with nix, which is probably better than using a Dockerfile. However, neither this nor the dockerfile approach will allow you to actually upload paths. You may prefer an nginx serving files from a static folder which you fill using nix copy.

pinpox commented 3 years ago

@lheckemann Could you elaborate on that? I've setup a cache with nix-serve, but I'm concerned about using the host's nix-store for it. Is it possible to have a separate store that is just for the cache?

How can nginx serving static files be a valid cache, is the nix caching mecahnism that simple?

lheckemann commented 3 years ago

Yes, a binary cache consists of a bunch of .narinfo files which contain some metadata (including signatures) on paths and .nar files representing the actual contents of the store paths. You can create one using e.g. nix build nixpkgs.hello && nix copy ./result --to /var/www/nix-cache and serving /var/www/nix-cache via nginx or similar.