Running NixOS on Proxmox

One of the stumbling blocks I ran into when trying out NixOS was that I couldn’t run it under Proxmox, my preferred virtual machine server.

Through some trial and error, I figured out how to install NixOS as a Proxmox container.

Download the NixOS container image ๐Ÿ”—︎

First, download the latest NixOS x86_x64 container image. For other hardware architectures, see this Github comment.

At the time of this writing, the latest NixOS container build is 235933548, but you can just click whatever is the latest build as you read this.

Screenshot of latest builds page, showing a NixOS container image build each day.

From the build result page, click the link labeled nixos-system-x86_64-linux.tar.xz to download the image:

Screenshot of metadata page for a NixOS build from 2023-09-21

Rename the NixOS container image (optional) ๐Ÿ”—︎

The NixOS container image download doesn’t include any version or date information. For organization, I renamed my image file to:

  • nixos-2023-09-21-lxdContainerImage.x86_64-linux.tar.xz

Renaming will help you identify which version of NixOS this is when you see it later in Proxmox, though this step is optional.

Upload the image to Proxmox ๐Ÿ”—︎

Now, it’s time to upload the image to Proxmox. Scroll down to one of your Proxmox storage nodes.

Click the storage node you’d like to use. The default is called local, but you may have others.

Screenshot of local storage node menu item in the Server View of Proxmox

From the storage node, click “CT Templates,” and then click “Upload.”

Screenshot of settings pages for storage node, showing the CT Templates tab is selected and an arrow pointing to the Upload button

In the upload dialog, click “Select File…” and select the NixOS container image you downloaded above, and click “Upload.”

Screenshot of template upload dialog with content set to 'Container template'

Create a NixOS container ๐Ÿ”—︎

Now that your Proxmox server has the NixOS image available, you can create your first NixOS container.

Scroll up to your Proxmox node, right click it, and select “Create CT”:

Screenshot of Proxmox context menu for pve node with an arrow pointing to 'Create CT' menu option

In the “Hostname” field, select any hostname you’d like, such as nixos1.

Screenshot of first page of Create LXC Container wizard. Hostname is set to nixos1, Node is set to pve. CT ID is set to 151. Other fields are not populated.

The Proxmox dialog requires you to fill out the password fields, but they have no effect in NixOS. Put in any value you want.

Ignore the SSH public key field, as it has no effect within NixOS.

On the Template tab, choose the NixOS image you uploaded above:

Screenshot of Template tab of Create LXC Container wizard showing that nixos-2023-09-21-lxdContainerImage.x86_64-linux.tar.xz is the template being selected

Proceed through the container creation wizard normally, choosing your preferred values for disk, CPU, memory, and network.

On the last page, leave “Start after created” unchecked and click “Finish.”

Screenshot of summary screen of Create LXC Container wizard showing that 'Start after created' is unchecked

The output will contain these warnings, which are safe to ignore:

Architecture detection failed: open '/bin/sh' failed: No such file or directory

Falling back to amd64.
Use `pct set VMID --arch ARCH` to change.
unknown ID 'nixos' in /etc/os-release file, trying fallback detection
/etc/os-release file not found and autodetection failed, falling back to 'unmanaged'

Enable nesting ๐Ÿ”—︎

For NixOS to work properly under Proxmox, you need to enable the “Nesting” feature of the container.

Navigate to the NixOS container you just created, then click the Options tab, and click “Features.”

Screenshot of settings tab for new Proxmox container. The Options tab is selected and there's an arrow pointing to the 'Features' row

Click the box next to “Nesting” and then hit “OK.”

Screenshot of the Proxmox Edit Features dialog showing that Nesting is now checked

Start NixOS ๐Ÿ”—︎

Your NixOS container is now configured!

You can start your container normally. At the Console, you should see a standard NixOS prompt:

Screenshot of nixos default login prompt in a Proxmox container on the Console tab

As the prompt says, you can log in with username root and no password.

Configure NixOS system ๐Ÿ”—︎

I’ve created a basic configuration for a NixOS server system as a Proxmox container. You can download this configuration by running the following command:

curl \
  --show-error \
  --fail \ \
  | sudo tee /etc/nixos/configuration.nix

Apply the new configuration by running the following commands:

sudo nixos-rebuild boot && \
  echo "install complete, rebooting..." && \
  sudo poweroff --reboot

References ๐Ÿ”—︎