edolstra / nix-serve

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

question: "mirror mode" #54

Open caarlos0 opened 10 months ago

caarlos0 commented 10 months ago

A couple of days ago I decided to try and run a binary cache on my local network to understand better how it works.

Per my understanding, nix-serve will only serve files already on the nix store of the machine that's running it, is that correct?

Is it possible to make it so that, if any machine requests it, it tries to get it from another cache? (act like a mirror)

Or, for things like nixos-rebuild to publish the newly installed packages there automatically?

Thank you!

PS: I'm fairly new to nix

SuperSandro2000 commented 10 months ago

Per my understanding, nix-serve will only serve files already on the nix store of the machine that's running it, is that correct?

yes

Is it possible to make it so that, if any machine requests it, it tries to get it from another cache? (act like a mirror)

I don't think that feature exists currently

Or, for things like nixos-rebuild to publish the newly installed packages there automatically?

You can copy the build system afterwards to the cache with the help of a thin wrapper.

caarlos0 commented 10 months ago

for anyone else trying to achieve this, I ended up doing the following:

the only issue I had is that I the user that runs the ssh command is root, so I had to create a public key for it and add it to the cache's authorized keys file. Is there a better way?