Building AMIs with Nix

You can also generate images without starting an instance and the cleanup. This is basically what we do for the NixOS AMI’s. You can find the script for that at: https://github.com/NixOS/nixpkgs/blob/master/nixos/maintainers/scripts/ec2/create-amis.sh

It should be easy to adapt this to a custom NixOS configuration. The line in the script that does the image building is https://github.com/NixOS/nixpkgs/blob/master/nixos/maintainers/scripts/ec2/create-amis.sh#L34 . You should be able to just reference your configuration in the imports list there.