Migrating my Home Assistant instance from HAOS to NixOS (on Proxmox)

05 Dec 2026 I recently migrated my Home Assistant instance from a Home Assistant OS (HAOS) VM on Proxmox to a NixOS VM, also on Proxmox.

What made this migration especially interesting is that it was almost entirely LLM-driven: an agent (Gemini) audited my live HAOS instance, wrote the migration plan, generated the NixOS configuration, built a custom backup-import script, and produced the exact cutover commands.

If you’d like to watch the full walkthrough - including the first-try cutover on Proxmox - you can check out the companion video:

Why leave HAOS?

I’m in the middle of migrating my Proxmox-based home server over to a NixOS-based home server. My current Proxmox host runs a collection of VMs (mostly running NixOS), and as a prerequisite step, I wanted to migrate the non-NixOS VMs over to NixOS first.

Home Assistant was a clear candidate. Running Home Assistant OS as a VM has been stable and works well out of the box, but it’s heavily UI-driven, and when you inevitably have to drop into YAML, it becomes difficult to track what changed, when, and why. Even more importantly, it’s a bit too abstracted for my taste with the custom shell and Supervisor addons (or apps?) running external services (e.g. Zigbee2MQTT). Moving it to NixOS brings the whole setup into declarative, version-controlled code alongside the rest of my infrastructure.

However, before committing to the move, I wanted to answer a simple question: how feasible is it to migrate my existing HAOS setup to NixOS?

Step 1: AI-driven introspection and feasability planning

Instead of manually clicking through every settings page in HAOS to take inventory, I handed the discovery work over to Gemini.

I wrote a short, one-paragraph prompt explaining the context along with what I wanted to evaluate. Then - and this was the crucial part - I generated a fresh Home Assistant API key and gave it to the agent, instructing it to poke around and introspect the running instance to figure out what existed today, what could move cleanly to NixOS, and what couldn’t. The Home Assistant API exposes quite a bit, which works well for this kind of workflow.

I want you to scope out the work required to setup HAOS on NixOS. Note that this is NOT part of the current plan, nor do I want you to update the current plan. I just want you to scope things out. HAOS currently doesnt have too many plugins installed: primary ones are Zigbee to MQTT, Shell (probably no longer needed).

UI is available at http://192.168.30.10:8123/, and here is an API token: [REDACTED]

Do whatever digging is needed and report back.

From this, Gemini was able to produe a full migration report (complete with an architecture diagram!) concluding that the migration was not only feasible, but relatively straightforward.

What the LLM uncovered

Giving the agent direct API access let it surface details I might easily have overlooked during a manual audit:

  • Versions & resource sizing: It captured the current software versions and VM specs, and correctly noted that a lean NixOS VM could likely run on fewer CPU cores and less RAM than HAOS.
  • Dual-NIC VLAN setup: It detected that Home Assistant was using two separate network interfaces for network-level isolation:
  • One NIC on my trusted VLAN , used to access the web UI and mobile app.
  • A second NIC on a locked-down IoT VLAN , strictly for IoT device discovery.
  • One NIC on my
  • USB dongle passthrough: It spotted the attachedZigbee USB dongle that would need to be passed through and configured on the NixOS side.(Side note: I’m a huge fan of Zigbee and highly recommend Zigbee devices whenever you have the option.)
  • Users: It accounted for the two configured Home Assistant users.
  • HAOS Supervisor add-ons: Supervisor add-ons are special companion services that only exist inside HAOS. Gemini zeroed in on these right away and confirmed they could be swapped for native NixOS services, and one could be dropped altogether in favor of standard OpenSSH.
  • Devices & integrations: Using the API, it inventoried all devices and integrations and checked that every integration was natively packaged in Nixpkgs.
  • Hidden/subtle dependencies: One of its best catches was flagging an automation that copies Nest doorbell clips to an NFS mount. Setting up an NFS mount in NixOS is trivial, of course, but catching that dependency*before* cutover saved me from a silent breakage later.

Step 2: Building the NixOS config in a fresh context

Once I was happy with the report, I fed the generated plan into a fresh LLM session and had Gemini iterate on the actual implementation.

This is where NixOS really shines for AI-assisted infrastructure work: because the entire system is defined in code, the agent can build the configuration locally and get immediate, deterministic verification before anything ever touches Proxmox.

Working from the plan, Gemini produced three artifacts:

  1. The NixOS configuration for the Home Assistant VM (covering networking, native NixOS replacements for Supervisor add-ons, NFS mount, and OpenSSH)
  2. A disko-based VM disk image ready to import into Proxmox
  3. A tailor-made migration script to extract and import state from a backup of the running HAOS instance into the new VM

Code snippets

# hosts/sfax/default.nix
{ lib, pkgs, modulesPath, ... }:

{
  imports = [
    (modulesPath + "/profiles/qemu-guest.nix")

    ../../shared/default.nix # config shared across all of my machines

    ./disko.nix
    ./home-assistant
    ./proxy.nix # Nginx reverse proxy + LetsEncrypt via Cloudflare DNS
    ./zigbee.nix
  ];

  # Setup my user (NixOS + Home Manager config)
  ksiksi.users.aksiksi.enable = true;

  # Bootloader
  boot.loader.systemd-boot = {
    enable = true;
    configurationLimit = 50;
  };
  boot.loader.efi.canTouchEfiVariables = true;
  boot.growPartition = true;

  # Networking
  systemd.network.networks = {
    "10-lan" = {
      matchConfig.MACAddress = "..."; # Trusted VLAN NIC
      address = [ "192.168.10.30/24" ];
      gateway = [ "192.168.10.1" ];
      dns = [ "192.168.10.2" ]; # Pi-hole
    };
    "11-iot" = {
      matchConfig.MACAddress = "..."; # Untrusted VLAN NIC
      address = [ "192.168.30.10/24" ];
    };
    # Fallback DHCP when booted pre-cutover.
    "20-dhcp-fallback" = {
      matchConfig.Type = "ether";
      networkConfig.DHCP = "yes";
    };
  };

  # NFS client and automount
  boot.supportedFilesystems = [ "nfs" ];
  environment.systemPackages = [ pkgs.nfs-utils ];
  services.rpcbind.enable = true;
  systemd.mounts = [
    {
      type = "nfs";
      what = "192.168.10.3:/pool/home";
      where = "/mnt/home";
      mountConfig.Options = "nfsvers=4,async,noatime,nodiratime,defaults,nofail";
      wantedBy = [ "multi-user.target" ];
    }
  ];

  # Proxmox integration
  services.qemuGuest.enable = true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}
# hosts/sfax/home-assistant/default.nix
{ ... }:

{
  imports = [
    ./tasks.nix # systemd timers to replace HA scripts/automations
  ];

  services.home-assistant = {
    enable = true;
    extraComponents = [
      "default_config"
      "dhcp"
      "mobile_app"
      "mqtt"
      "ssdp"
      "usb"
      "zeroconf"
      # ... other device/service integrations
    ];
    config = {
      default_config = {};

      homeassistant = {
        allowlist_external_dirs = [ "/mnt/home" ];
      };

      logger.default = "critical";

      # Migrated static config
      automation = "!include automations.yaml";
      script = "!include scripts.yaml";
      scene = "!include scenes.yaml";

      # Declarative config
      "automation nix" = "!include ${./automations.yaml}";
      "script nix" = "!include ${./scripts.yaml}";
      "scene nix" = "!include ${./scenes.yaml}";

      # Sidebar tab for Z2M
      lovelace.dashboards.zigbee2mqtt-ui = {
        mode = "yaml";
        title = "Zigbee2MQTT";
        icon = "mdi:zigbee";
        show_in_sidebar = true;
        require_admin = true;
        filename = "${./dashboards/z2m.yaml}";
      };
    };
  };
}
# hosts/sfax/disko.nix
# Disko partitioning config used to generate a "baked" VM image ready for Proxmox
{ lib, ... }:

{
  disko = {
    memSize = 4096;
    imageBuilder.imageFormat = "qcow2";

    devices.disk.sda = {
      type = "disk";
      device = lib.mkDefault "/dev/sda";
      imageName = "sfax";
      imageSize = "32G";

      content = {
        type = "gpt";
        partitions = {
          esp = {
            name = "ESP";
            size = "500M";
            type = "EF00";
            content = {
              type = "filesystem";
              format = "vfat";
              mountpoint = "/boot";
              mountOptions = [ "umask=0077" ];
            };
          };
          root = {
            size = "100%";
            content = {
              type = "filesystem";
              format = "ext4";
              mountpoint = "/";
              mountOptions = [ "x-systemd.growfs" ];
            };
          };
        };
      };
    };
  };
}

Step 3: Testing with a local VM

Before shipping the disk image over to Proxmox, NixOS makes it straightforward to go one step beyond a clean evaluation/build: booting the configuration in a local VM. This lets you verify that the system boots cleanly, services start up as expected, and there are no obvious runtime or configuration issues, without touching your running HAOS instance.

# 1. Build disko qcow2 image
# This will boot the VM in QEMU, partition disks via disko, and finally run the NixOS installer.
nix build .#nixosConfigurations.sfax.config.system.build.diskoImages

# 2. Create a writable CoW overlay backed by the Nix store image
nix shell nixpkgs#qemu_kvm -c qemu-img create -f qcow2 -b "$(readlink -f result/sfax.qcow2)" -F qcow2 /tmp/sfax-local.qcow2

# 3. Boot locally in QEMU with KVM + UEFI + port forwards (SSH :2222, HA :18123, Z2M :18080)
nix run nixpkgs#qemu_kvm -- \
   -machine q35 -enable-kvm -cpu host -smp 4 -m 4096 \
   -display none \
   -bios "$(nix build nixpkgs#OVMF.fd --no-link --print-out-paths)/FV/OVMF.fd" \
   -device virtio-scsi-pci,id=scsi0 \
   -drive file=/tmp/sfax-local.qcow2,if=none,id=hd0,format=qcow2 \
   -device scsi-hd,drive=hd0 \
   -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::18123-:8123,hostfwd=tcp::18080-:8080 \
   -device virtio-net-pci,netdev=net0

# 4. Sanity checks (in another terminal)
ssh -p 2222 aksiksi@localhost -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "hostname && systemctl is-active mosquitto home-assistant systemd-networkd && ip -br a"
curl -sSI http://localhost:18123/ | head -n 5

Step 4: Live cutover on Proxmox

Here is how the cutover played out:

# 1. Copy qcow2 image to Proxmox
rsync -avh --progress --copy-links result/sfax.qcow2 root@192.168.0.100:/tmp/sfax.qcow2

# 2. Create VM 111 for staging (temporary MAC on VLAN 10 -> DHCP fallback)
ssh root@192.168.0.100 "qm create 111 --name sfax --ostype l26 --machine q35 --bios ovmf --efidisk0 vmpool:1,efitype=4m,pre-enrolled-keys=0 --scsihw virtio-scsi-single --cores 4 --sockets 1 --memory 4096 --agent 1 --net0 virtio,bridge=vmbr0,firewall=1,tag=10"

# 3. Import qcow2 onto vmpool (lands at vm-111-disk-1 since efidisk0 took disk-0)
ssh root@192.168.0.100 "qm importdisk 111 /tmp/sfax.qcow2 vmpool && rm -f /tmp/sfax.qcow2"

# 4. Attach disk and boot for staging
ssh root@192.168.0.100 "qm set 111 --scsi0 vmpool:vm-111-disk-1,iothread=1 --boot order=scsi0 && qm start 111"

# 5. Deploy migrated HAOS backup onto staged VM via tailor-made migration script (replace <DHCP_IP>)
# Also copies over Zigbee2MQTT state to keep existing devices paired on the new VM.
nix run nixpkgs#python3 -- hosts/sfax/migrate-backup.py /tmp/manual.tar --deploy aksiksi@<DHCP_IP> --no-start

# 6. Cut over: shut down sfax (111) + HAOS (101, disable autostart), assign VLAN MACs + Zigbee dongle, and start sfax
ssh root@192.168.0.100 "qm shutdown 111 && qm shutdown 101 && qm set 101 --onboot 0"
ssh root@192.168.0.100 "qm set 111 --net0 virtio=[REDACTED],bridge=vmbr0,firewall=1,tag=10 --net1 virtio=[REDACTED],bridge=vmbr0,firewall=1,tag=30 --usb0 host=[REDACTED] --onboot 1 && qm start 111"

# 7. Allow sfax (192.168.10.30) on pool/home NFS export (if not already done)
ssh root@192.168.0.100 'zfs set sharenfs="sec=sys,rw=@192.168.10.20/32:@192.168.10.10/32:@192.168.10.30/32,crossmnt,no_subtree_check,insecure" pool/home && zfs share -a'

# 8. Verify HA + Zigbee2MQTT on production IP
curl -sSI http://192.168.10.30:8123/ | head -n 5
curl -sSI http://192.168.10.30:8080/ | head -n 5

The VM booted cleanly into NixOS on Proxmox.

原文来源:assil.me