Building sparse/thin provisioned nixos disk images

I run macos and MacOS’s built in virtualisation to run a development VM which I build with nixos-rebuild build-image … and the workflow is very nice - would recommend it if you haven’t tried it.

However currently none of the generator formats support Apples sparse (asif) disk image format meaning I have to use raw-efi.

The issue with raw-efi is that it doesn’t allow sparse/thin provisioning the image meaning if I allocate a 200GB disk the .img file is 200GB whether it’s been used or not.

It doesn’t seem like there is that much activity on the nixos-generators so I am not hopeful for an ASIF generator so have been thinking about a possible conversion path - perhaps build a qcow2 image (which is sparse) and then run a conversion? Or perhaps there is a way to compress a raw disk image that I’m not aware of?

Thought I would put it out there in case anybody has experienced a similar dilemma and potentially has any thoughts on how I could achieve this?