deploying nixos on proxmox
I’ve been using NixOS for a while now, primarily to provision my personal and work Mac systems. While Nix can be complex and sometimes challenging to debug, I’ve enjoyed its unique approach to system configuration. However, I haven’t explored much beyond that scope. For some time, I’ve become particularly interested in using it for containers, as NixOS offers compelling features—reproducibility, declarative configuration, and reliable upgrades—which, in theory, make it an excellent choice. How well this theory holds up is something I’m eager to explore further. In this post, I’m documenting my steps for installing NixOS on Proxmox, my chosen virtual environment solution for my home server, as deploying NixOS onto my home server should help me further explore using it for configuring my containers
Loading the NixOS Container Image #
The first step is to load the NixOS container image onto my Proxmox host as a CT template, so that new containers can be created with this base image. At the time of writing, the latest NixOS LXD container image I found was version
276346783, but you’ll likely want to download the most recent image available
here. You’ll need to copy the URL under ‘Link’ for the system tarball; for my build, this was https://hydra.nixos.org/build/276346783/download/1/nixos-system-x86_64-linux.tar.xz
.
Next, in Proxmox, I loaded the container using the ‘Download from URL’ button on the “CT Templates” page for my hosts local storage. Clicking on the button a modal will open up, enter the URL, and gave it a descriptive name, for example I used ’nixos-2024-10-25-system-x86_64-linux.tar.xz’.
Create a NixOS Container #
At first, I attempted to configure a new container through the Proxmox UI. However, based on various resources I found online, there were some issues with this approach, so I ultimately needed to create a new container via the command line.
After referencing the NixOS Wiki and other sources, I came up with the following command to create a new container:
pct create "$(pvesh get /cluster/nextid)" \
--arch amd64 \
"local-lvm:vztmpl/nixos-2024-10-25-system-x86_64-linux.tar.xz" \
--ostype unmanaged \
--description nixos \
--hostname "thermic" \
--net0 name=eth0,bridge=vmbr0,ip=dhcp,firewall=1 \
--storage "local-lvm" \
--memory "2048" \
--rootfs local-lvm:10 \
--unprivileged 1 \
--features nesting=1 \
--cmode console \
--onboot 1 \
--start 1
Some of these settings are specific to my setup and may differ for yours, but hopefully, this provides a helpful starting point.
Logging into NixOS #
NixOS should now be running as an LXC container on Proxmox. If you navigate to the console, you may initially see a black screen, which might seem odd. However, simply press ‘Enter,’ and you’ll be prompted with a login screen. Enter the username ‘root’ and press ‘Enter’ again to log into your fresh NixOS container.
Next Steps #
Now that I have the container up and running, my next steps are to create a configuration to install PostgreSQL, setup any monitoring I need and to set up and run a Go app I’ve been developing.
Looking ahead, I’m also interested in building a preconfigured NixOS image with all necessary configuration and setup, ready to run any application I choose.