First generate the image script:
$ nix build .#nixosConfigurations.myhost.config.system.build.diskoImagesScript
Next we build the image:
$ sudo ./result --build-memory 2048
In our example the script will generate the following image:
$ ls -la vdb.raw
.rw-r--r-- root root 10 GB 2 minutes ago vdb.raw
The build script has more options as you can see here:
$ ./result --help
Usage: $script [options]
Options:
* --pre-format-files <src> <dst>
copies the src to the dst on the VM, before disko is run
This is useful to provide secrets like LUKS keys, or other files you need for formating
* --post-format-files <src> <dst>
copies the src to the dst on the finished image
These end up in the images later and is useful if you want to add some extra stateful files
They will have the same permissions but will be owned by root:root
* --build-memory <amt>
specify the ammount of memory that gets allocated to the build vm (in mb)
This can be usefull if you want to build images with a more involed NixOS config
By default the vm will get 1024M/1GB