NixOS generate

NixOS generate is a flake output which allows generating different target formats from NixOS configurations.

The output type is implemented in nixos-generators which documents the available formats.

How to use NixOS generate

Step 1 - Create your flake

Create a flake by signing in to MyNixOS, and then navigate to the create flake page.

On the flake create screen, enter an appropriate name, then click "create".

You should now see the name of your flake in the flake selector to the upper right on your screen.

Step 2 - Create a NixOS generate output

  • Navigate to the flake outputs screen by clicking the flake selector to the top right of the screen, then select "Outputs" to the left on the flake screen.
  • From the flake outputs screen, select "Add output" → "NixOS generate".
  • In the "NixOS generate" dialog, select a name, your target system, and target format, then click "Create".
    In this example, we select x86_64-linux as the system and virtualbox as the format.

Your NixOS generate should now be shown as an output in the flake output screen.

Step 3 - Configure the NixOS generate output

As part of our configuration, we will add the following settings to the NixOS generate:

Step 4 - Create the NixOS generate artifact

After completing our flake configuration, we can now create the NixOS generate artifact.

  • Navigate to the flake versions screen (Click the flake selector, then select "Versions").
  • Click "Release" to create a version of your flake (Learn about releases)
    When the release is ready, a new version entry appears in the listing on the flake versions page.
  • Click "Build" → "nixos" to start a build of your NixOS generate.
    When the build is completed, a link to download the NixOS generate artifact will appear with the released flake version.
  • Click the artifact link to download the NixOS generate artifact, then unpack it locally.

Step 5 - Run NixOS generate artifact

To run the VirtualBox artifact created in this example, perform the following:

  1. Open VirtualBox and select "File" → "Import Appliance".
  2. Browse and select the OVA-file unpacked from the downloaded artifact.
  3. Select "Next", then uncheck "USB Controller" if you do not have VirtualBox host extensions installed, then select "Import".
  4. Press "Start" to boot.
  5. Log in with username nixos and password nixos.

Congratulations! You are now running a NixOS generate that you have built!

To celebrate, run the nyancat command from your virtual machine terminal.