Dependency closure "erasure" over ISO file boundaries

Hi there,

i have a situation where i would like to boot an initial ramdisk, and the initial ramdisk basically just starts a VM.
The VM is basically just some hypervisor booting a bootable ISO.

I cannot post a minimal sample right now so i hope the following information is enough to give a complete problem statement:

On the nix expression level, the script is a writeScript derivation that references both the hypervisor binaries and the ISO from the nix store. The hypervisor might for example be qemu from nixpkgs.
The ISO is its own derivation which simply outputs a store path that is just /nix/store/213213213213-myiso.iso.

Now, in order to calculate the contents that should go into the initial ramdisk, one would simply calculate the closure of this script and get all those store paths into the initrd.

This does work. The initrd contains enough to run the whole scenario. Unfortunately, if you ask the nix store about the dependencies of the ISO, it lists all the things that the ISO contains already. That means that my initrd contains the ISO plus its contents in addition to that in the initrd nix store.

E.g. if you query the closure info of the installer iso of nixos, you get the whole list:

nixpkgs $ nix-store -qR $(nix-build nixos/release.nix -A iso_minimal)

Is there some possibility to let nix “stop” calculating the dependencies at ISO boundaries, as the ISO is selfcontained and does not have any other deps in order to be booted in a VM?

In nixpkgs, references known to be unneeded are often removed using nuke-references or remove-references-to, which replace the hashes with invalid ones. This won’t work in your case though, since the paths are actually used in the initramfs.

A somewhat questionable “solution” to this is compressing the resulting image (then decompressing it for use), so the references are no longer detected.

I’m not aware of a way to tell nix “no really, this path doesn’t depend on that one, I promise o:)” while leaving the references unmodified.