UpdateNixosVm

Update phase for a NixOS-backed VM on a Proxmox host. Runs every cycle.

Note

Drift-correction: every cycle pushes the current base nix tree (extracted from EnsureNixosConfigTreeOnProxmoxHost) plus a freshly-rendered per-VM overlay onto the installed VM, then runs nixos-rebuild boot and reboots.

Skip conditions:

  • VM not present on Proxmox host (Install never ran).

  • Guest agent hostname != machine.Name (Install in flight or failed; nothing to update).

In both cases this method is a no-op; the install step is responsible for getting the VM into a state Update can act on.

public static class UpdateNixosVm

1. Fields

1.1. RebuildTimeout

Default ceiling for nixos-rebuild boot. Cache miss + closure build can take a while.

public static readonly TimeSpan RebuildTimeout

2. Methods

2.1. Run(Host, SystemManagement.Entities.Machine, NETSetupConfig, ISystemHost)

Production entry. Resolves shared helpers via ProvisionNixosVm, wires real rsync/rebuild/reboot via NixRemoteUpdateCommand.

public static UpdateNixosVmResult Run(Host proxmoxHost, SystemManagement.Entities.Machine machine, NETSetupConfig config, ISystemHost sysHost)
Table 1. Parameters
Name Type Description

proxmoxHost

Host

machine

SystemManagement.Entities.Machine

config

NETSetupConfig

sysHost

ISystemHost

Returns: UpdateNixosVmResult

2.2. RunCore(SystemManagement.Entities.Machine, Func<IPAddress>, Action<AbsolutePath>, Action<IPAddress, AbsolutePath>, ILogger)

Testable core. Each external action is a delegate seam unit tests can stub.

public static UpdateNixosVmResult RunCore(SystemManagement.Entities.Machine machine, Func<IPAddress> discoverIp, Action<AbsolutePath> emitOverlay, Action<IPAddress, AbsolutePath> rsyncAndRebuild, ILogger logger)
Table 2. Parameters
Name Type Description

machine

SystemManagement.Entities.Machine

discoverIp

Func<IPAddress>

emitOverlay

Action<AbsolutePath>

rsyncAndRebuild

Action<IPAddress, AbsolutePath>

logger

ILogger

Returns: UpdateNixosVmResult