Hi,
I think you are looking for nixos/lib/make-disk-image.nix
If you look inside nixpkgs you can see how to use it, for example:
system.build.qcow = import <nixpkgs/nixos/lib/make-disk-image.nix> {
inherit lib config pkgs;
diskSize = 10240;
format = "qcow2";
};
The result of building this attribute will be a qcow2 image of the current
configuration ready to be run with qemu.
Excerpts from Gestur Bjarkason via NixOS Discourse’s message of February 2, 2020 1:40 pm: