MyNixOS website logo
flake

nixos-generators

Nixos-generators - one config, multiple formats

mnos-flake-nav navigation

README.md

deprecated: nixos-generators

Starting with NixOS 25.05, most of nixos-generators has been upstreamed into nixpkgs.

So we believe it's time to retire nixos-generators, a good 8 years after its initial commit and after countless built images. Please let us know if you run into any trouble, such as missing features, during the migration.

The main, user-visible difference is the new nixos-rebuild build-image command, which replaces the venerable nixos-generate. Check its manual section or below to see how it works.

Usage of nixos-rebuild build-images

To build an ISO image, using the new nixos-rebuild build-image, run:

nixos-rebuild build-image --image-variant iso

Or to explicitly specifiy the path to your NixOS configuration as well as the nixpkgs checkout to use:

NIX_PATH=nixpkgs=../nixpkgs NIXOS_CONFIG="/etc/nixos/nixos-configuration.nix" nixos-rebuild build-image --image-variant iso

...with Flakes

To build a simple ISO image, from a nixosConfigurations.myhost output of your flake, run:

nixos-rebuild build-image --image-variant iso --flake .#myhost

Or, if you prefer to expose an installable similar to the old nixos-generators.nixosGenerate nix function, you could use the right attribute of system.build.images:

packages.x86_64-linux.myhost-iso = self.nixosConfigurations.myhost.config.system.build.images.iso

Formats of nixos-generators

The third column describes whether they are supported image variants in nixos-rebuild build-image:

formatdescriptionsupported in nixpkgs
amazonAmazon EC2 image
azureMicrosoft azure image (Generation 1 / VHD)
cloudstackqcow2 image for cloudstack.
doDigital Ocean image
dockerDocker image (uses systemd to run, probably only works in podman)
gceGoogle Compute image
hypervHyper-V Image (Generation 2 / VHDX)
install-isoInstaller ISO✅ (called iso-installer)
install-iso-hypervInstaller ISO with enabled hyper-v supportuse the hyperv variant and customize it.
isoISO
kexeckexec tarball (extract to / and run /kexec_nixos)
kexec-bundlesame as before, but it's just an executableUse the kexec variant above.
kubevirtKubeVirt image
linodeLinode image
lxccreate a tarball which is importable as an lxc container, use together with lxc-metadata
lxc-metadatathe necessary metadata for the lxc image to start, usage: lxc image import $(nixos-generate -f lxc-metadata) $(nixos-generate -f lxc)
openstackqcow2 image for openstack
proxmoxVMA file for proxmox
proxmox-lxcLXC template for proxmox
qcowqcow2 image
qcow-efiqcow2 image with efi support
rawraw image with bios/mbr. for physical hardware, see the 'raw and raw-efi' section
raw-efiraw image with efi support. for physical hardware, see the 'raw and raw-efi' section
sd-aarch64Like sd-aarch64-installer, but does not use default installer image config.use sd-card and set system to aarch64-linux
sd-aarch64-installercreate an installer sd card for aarch64. For cross compiling use --system aarch64-linux and read the cross-compile section.use sd-card and set system to aarch64-linux
sd-x86_64sd card image for x86_64 systemsuse sd-card and set system to x86_64-linux
vagrant-virtualboxVirtualBox image for Vagrant
virtualboxvirtualbox VM
vmonly used as a qemu-kvm runneruse nixos-rebuild build-vm
vm-bootloadersame as vm, but uses a real bootloader instead of netbootinguse nixos-rebuild build-vm-with-bootloader
vm-noguisame as vm, but without a GUIuse nixos-rebuild build-vm and customize it.
vmwareVMWare image (VMDK)