Jack Palauskas

Sometimes I like to make things.


Deploying NixOS on Proxmox with Cloud-init

Back in 2007, I deployed a Hypervisor for the first time on VMware Elastic Sky (ESXi) 3.5. I’ll never forget the excitement of being able to run multiple virtual computers inside of a box. Watching the barriers between hardware and software evaporate into raw abstraction was something magical. I was no longer limited to my previous bare-metal presuppositions.

Flash forward a decade and a half or so, and we live in a completely different computing. DevOps simply didn’t exist back then (Atleast not in its modern form). NPM? Node.JS? Tensorflow? Gibberish. But now we live in era of software definition. My ESXi node has since grown into a multi-thousand VM Proxmox group.

The question becomes, as we evolve from pet-style computing, to massive livestock operations of ephemeral nodes, how do we handle application deployment within that? Cloud-init has become integral to pretty much every datacenter in the world, AMIs in AWS, and other forms of imaging have taken over the Linux deployment space at scale.

NixOS has been key to many industries, and with it the ability to make instantly reproducible builds. I use NixOS frequently on Proxmox, and While I do not claim to be an expert on the Nix language I do have a working configuration for NixOS and Proxmox that works with Cloud-init

{ config, pkgs, ... }:

{
  imports = [];

  # Enable the qemu-guest-agent service
  services.qemuGuest.enable = true;

  # Ensure that the qemu-guest-agent package is installed
  environment.systemPackages = with pkgs; [
  ];

  # Cloud-Init configuration
  services.cloud-init.enable = true;
  services.cloud-init.network.enable = true;

  # Network configuration should be managed by cloud-init, no static configuration here
  # networking.useDHCP = false;
  # networking.interfaces = {}; # This line ensures NixOS does not manage any interfaces on its own.

  # Additional configuration can be added here
}

This configuration does the following:

  1. It enables QEMU Guest Agent support for viewing broader metrics in the Proxmox UI
  2. It enables network configurations including IP assignment and DNS to be assigned by cloud-init
  3. It allows you to disable DHCP inside of the file (But I manually disable inside of Hardware-configuration.nix – which is not directly advised, but I do NOT use hardware-generate so It doesn’t matter to me)