Conditionally include VM attributes

I use nixos-generators to build vm’s and sometimes have to switch between vm formats. In some cases, this is as easy as switching the --format argument to nixos-generate, but not when I need to set attributes like virtualisation.diskSize which exist for one vm format but no others.

Is there a way to test in the configuration if the machine is currently being built as a qemu vs virtualbox vs vmware vm and conditionally include only the appropriate attributes?