I need to test some changes in a QEMU VM that require running
nixos-rebuild, for example my GRUB PR.
For this purpose I’d like to build a VM as described on Mayflower’s post on this topic.
The problem is that even though I use the same config and nixpkgs version inside and outside the VM,
nixos-rebuild downloads GBs of store paths, even though they already exist via the read-only + overlay-file-system mount of
/nix/store of the host and I can
ls them from the guest.
I believe that this is because of what’s described in
The list of paths whose closure is registered in the Nix database in the VM. All other paths in the host Nix store appear in the guest Nix store as well, but are considered garbage (because they are not registered in the Nix database in the guest).
How can I configure my VM that either
- all of the host store paths are registered in the nix DB of the guest, or
- all store paths relevant to the VM are registered in the guest,
nixos-rebuild is a no-op inside the VM and causes no downloads?