NixRemoteUpdateCommand

Composite NETCommand for the per-cycle Nix VM update path. Pushes the current source-of-truth nix config tree onto an installed VM and runs nixos-rebuild boot + reboot. Drift-correct: every cycle re-pushes both the base tree and the per-VM overlay so manual edits get reverted.

Note

Phase sequence:

  • KeyScan: refresh known_hosts. The installed system has a different host key than the installer ISO, so first update after install always changes it.

  • Sync: rsync -a --delete base tree + rsync -a per-VM overlay (no --delete) to /etc/nixos/. Two rsyncs are simpler than a local merge + single rsync, and let the overlay carry per-VM secrets without staging on the Proxmox host.

  • Commit: git -C /etc/nixos add -A && git commit --allow-empty -m "netsetup update". Flakes only see tracked files; without this, edits never reach the build.

  • Rebuild: nixos-rebuild boot --flake /etc/nixos#default. boot not switch: activate only on next boot, so the reboot below gives a clean transition with no half-applied units mid-rebuild.

  • Reboot: systemctl reboot. Detached so the ssh channel teardown doesn’t race the reboot.

public sealed class NixRemoteUpdateCommand

1. Fields

1.1. RemoteFlakeDir

Target on-VM flake directory.

public const string RemoteFlakeDir

2. Properties

2.1. BaseTreeDir

Local directory containing the source-of-truth base nixos tree (EnsureNixosConfigTreeOnProxmoxHost.ProxmoxConfigTreePath).

public AbsolutePath BaseTreeDir { get; }

2.2. Hostname

Target hostname (== NixOS networking.hostName).

public string Hostname { get; }

2.3. Ip

Target VM ip (installed system, not installer ISO).

public IPAddress Ip { get; }

2.4. MasterKey

Private key for root ssh login.

public AbsolutePath MasterKey { get; }

2.5. OverlayDir

Local directory containing the per-VM overlay (config.nix + hardware.nix + secrets.yaml + .default.key) from ProvisionNixosVm.EmitConfigBundle.

public AbsolutePath OverlayDir { get; }

3. Methods

3.1. Execute(TimeSpan, ILogger)

Runs all phases sequentially. Stops on the first failure.

public NixRemoteUpdateResult Execute(TimeSpan rebuildTimeout, ILogger logger)
Table 1. Parameters
Name Type Description

rebuildTimeout

TimeSpan

logger

ILogger

Returns: NixRemoteUpdateResult

3.2. ToShellPath(AbsolutePath)

Native path on Linux; /mnt/c/... WSL form on Windows.

public static string ToShellPath(AbsolutePath p)
Table 2. Parameters
Name Type Description

p

AbsolutePath

Returns: string