Hosting a binary cache for airgapped hosts

Hey,

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:
  /nix/store/01n3wxxw29wj2pkjqimmmjzv7pihzmd7-which-2.21.tar.gz.drv
  /nix/store/883hki7vzya1zsy8c0f44hgqwgz9q7wy-gettext-0.20.1.tar.gz.drv
  /nix/store/b7irlwi2wjlx5aj1dghx4c8k3ax6m56q-busybox.drv
  /nix/store/bzq60ip2z5xgi7jk6jgdw8cngfiwjrcm-bootstrap-tools.tar.xz.drv
  /nix/store/wj70qz8syf2jv4lr58larhap39x9ywy8-bootstrap-tools.drv
  ...
  /nix/store/xhaaysyyg2agbncr7s872i6dxzppnvsv-bash44-022.drv
  /nix/store/ybxpl2sywkkwykydxgc1shqv3hh8akd7-bash44-017.drv
  /nix/store/rk2mypz949mcq43ij7bsn4sxjij2z397-bash-interactive-4.4-p23.drv
these paths will be fetched (0.00 MiB download, 5.46 MiB unpacked):
  /nix/store/mqqhgk2wg65s6z0fhv74vrzbch8x5xpa-niv-0.2.13-bin

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.

Thanks.

2 Likes

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