Hosting a binary cache for airgapped hosts


I’ve created NixOS image intended to be pxebooted using netboot.nix in nixpkgs and I can successfully do that. These hosts are booted in a network with no internet access.
In the same network I have spun up a machine running nix-serve and it has a second interface where I can push packages to its nix store. As a test I have pushed niv using nix-copy-closure to the nix-serve machine and I have set that host as the only binary cache in the netboot image.

However when I try running nix-shell -p niv on the pxe booted host I get the following (and there’s a lot of stuff in between the … gap):

> nix-shell -p niv
these derivations will be built:
these paths will be fetched (0.00 MiB download, 5.46 MiB unpacked):

This is a problem since this is a netboot image that will always be fresh after bootup and I’d like to be able to use nix-shell in there. I thought that nix-copy-closure would recursively push everything required for that derivation.

So I’m wondering if there’s something missing in the nix binary cache or the netboot image?

What is the minimum of derivations you should push into a binary cache before you can start cherry picking packages in there? I don’t want to host a complete mirror of nixpkgs.



Sorry for the late reply, this is probably related: Using NixOS in an isolated environment