ProvisionNixosVm

Shared helpers and constants for the Nix VM provisioning pipeline.

Note

Two-phase pipeline split (since the "split install/update" rework):

  • InstallNixosVm - one-shot install: createVm + ISO-side install.sh + power-cycle.

  • UpdateNixosVm - every cycle: rsync + nixos-rebuild boot + reboot.

This class no longer owns an orchestrator Run entry point; it carries only the helpers reused by both phases (key resolution, vm-id extraction, config emit, etc.).

public static class ProvisionNixosVm

1. Fields

1.1. DefaultInstallerKeyPath

Default live-deploy installer age private key path.

public static readonly AbsolutePath DefaultInstallerKeyPath

1.2. DefaultMasterKeyPath

Default live-deploy ssh master private key path (used to ssh into nix VMs as root).

public static readonly AbsolutePath DefaultMasterKeyPath

1.3. DiscoveryTimeout

Discovery timeout for qemu-guest-agent ip.

public static readonly TimeSpan DiscoveryTimeout

1.4. GeneratedNixRoot

Local root where generated nix configs are emitted. On Windows this must carry the drive letter: a bare "/NETSetup/…​" is drive-relative (files land on C:) but NixRemoteInstallCommand.ToShellPath cannot map it to the WSL "/mnt/c/…​" form, so the install script would cd into a nonexistent dir.

public static readonly AbsolutePath GeneratedNixRoot

1.5. InstallerAgePublicKey

Public age recipient that secrets.yaml is encrypted to.

public const string InstallerAgePublicKey

1.6. NixosIsoName

Name of the ISO on Proxmox iso storage used to boot nix VMs.

public const string NixosIsoName

2. Methods

2.1. CreateVmOnProxmox(Host, SystemManagement.Entities.Machine, NETSetupConfig, int, ILogger, IQmExecutor, NixHostTemplate)

Creates the Proxmox VM (per-template CPU/RAM/disk + scratch swap + nixos.iso boot) and returns the actual VM id assigned by Proxmox.

public static int CreateVmOnProxmox(Host proxmoxHost, SystemManagement.Entities.Machine machine, NETSetupConfig config, int wantedVmId, ILogger logger, IQmExecutor qm = null, NixHostTemplate templateOverride = null)
Table 1. Parameters
Name Type Description

proxmoxHost

Host

machine

SystemManagement.Entities.Machine

config

NETSetupConfig

wantedVmId

int

logger

ILogger

qm

IQmExecutor

templateOverride

NixHostTemplate

Returns: int

2.2. EmitConfigBundle(AbsolutePath, SystemManagement.Entities.Machine, NETSetupConfig, AbsolutePath, ILogger, IReadOnlyDictionary<string, string>, NixHostTemplate)

Emits the flat per-VM bundle into dir: config.nix, hardware.nix, secrets.yaml (sops to InstallerAgePublicKey), and .default.key.

public static void EmitConfigBundle(AbsolutePath dir, SystemManagement.Entities.Machine machine, NETSetupConfig config, AbsolutePath installerKeyPath, ILogger logger, IReadOnlyDictionary<string, string> dnsIpOverrides = null, NixHostTemplate templateOverride = null)
Table 2. Parameters
Name Type Description

dir

AbsolutePath

machine

SystemManagement.Entities.Machine

config

NETSetupConfig

installerKeyPath

AbsolutePath

logger

ILogger

dnsIpOverrides

IReadOnlyDictionary<string, string>

templateOverride

NixHostTemplate

2.3. ExtractVmId(SystemManagement.Entities.Machine)

Extracts the numeric VM id from machine.SerialNumber (form: <vmId>@<hostSerial>). Throws NETSetupException when not hosted or not numeric.

public static int ExtractVmId(SystemManagement.Entities.Machine machine)
Table 3. Parameters
Name Type Description

machine

SystemManagement.Entities.Machine

Returns: int

2.4. GeneratedConfigDirFor(string)

Returns the deterministic generated-config dir for vmName.

public static AbsolutePath GeneratedConfigDirFor(string vmName)
Table 4. Parameters
Name Type Description

vmName

string

Returns: AbsolutePath

2.5. ResolveDnsOverridesForMachine(Host, SystemManagement.Entities.Machine, NETSetupConfig, SystemManagement.Contracts.Elements.SerialNumber, ILogger)

For dns VMs only: discovers sibling installed Nix VM IPs so the emitted dns A records carry real LAN values. Returns null for non-dns machines.

public static IReadOnlyDictionary<string, string> ResolveDnsOverridesForMachine(Host proxmoxHost, SystemManagement.Entities.Machine machine, NETSetupConfig config, SystemManagement.Contracts.Elements.SerialNumber hostSerial, ILogger logger)
Table 5. Parameters
Name Type Description

proxmoxHost

Host

machine

SystemManagement.Entities.Machine

config

NETSetupConfig

hostSerial

SystemManagement.Contracts.Elements.SerialNumber

logger

ILogger

Returns: IReadOnlyDictionary<string, string>

2.6. ResolveInstallerKeyPath()

Resolves the installer age private key path.

public static AbsolutePath ResolveInstallerKeyPath()

Returns: AbsolutePath

2.7. ResolveMasterKeyPath()

Resolves the ssh master private key path.

public static AbsolutePath ResolveMasterKeyPath()

Returns: AbsolutePath

2.8. ResolveMasterPubKeyPath(ILogger)

Resolves the ssh master public key path; derives via ssh-keygen -y when missing.

public static AbsolutePath ResolveMasterPubKeyPath(ILogger logger)
Table 6. Parameters
Name Type Description

logger

ILogger

Returns: AbsolutePath

2.9. RunRemoteInstall(Host, SystemManagement.Entities.Machine, IPAddress, AbsolutePath, AbsolutePath, int, ISystemHost, IQmExecutor)

Runs the live-ISO install path: NixRemoteInstallCommand (scp + install.sh) then detach installer CD + swap disk + power-cycle into the installed system. Throws on failure.

public static void RunRemoteInstall(Host proxmoxHost, SystemManagement.Entities.Machine machine, IPAddress ip, AbsolutePath configDir, AbsolutePath masterKey, int vmId, ISystemHost sysHost, IQmExecutor qm = null)
Table 7. Parameters
Name Type Description

proxmoxHost

Host

machine

SystemManagement.Entities.Machine

ip

IPAddress

configDir

AbsolutePath

masterKey

AbsolutePath

vmId

int

sysHost

ISystemHost

qm

IQmExecutor