NixModelTemplate
Renders a NixHostModel into the three nix files the provisioning pipeline expects.
|
Note
|
The point of this class is that a NixOS role no longer needs its own C# subclass. Every other concrete template (NixIpfsTemplate, NixDnsTemplate, …) hardcodes its module text and its sops paths; this one takes them as data, so a role can be built, diffed and unit-tested without provisioning anything. It plugs into the unchanged InstallNixosVm / factory path because it is still just a NixHostTemplate.
|
public sealed class NixModelTemplate : NixHostTemplate
1. Constructors
1.1. NixModelTemplate(NixHostModel)
Creates a template that renders the supplied model.
public NixModelTemplate(NixHostModel model)
| Name | Type | Description |
|---|---|---|
model |
NixHostModel |
Host model to render. |
2. Properties
2.1. AuthorizedKeys
Authorized SSH public keys (one per line).
public IReadOnlyList<string> AuthorizedKeys { get; set; }
2.2. DiskDevice
Install-target block device (e.g. /dev/sda, /dev/vda).
public string DiskDevice { get; set; }
2.3. Gateway
Default gateway for static IPv4. Auto-derived from StaticIPv4 (.1) when null.
public string Gateway { get; set; }
2.4. Hostname
Target hostname.
public MachineName Hostname { get; set; }
2.5. Model
The model being rendered.
public NixHostModel Model { get; }
2.6. Nameservers
DNS servers used with static IPv4. Default falls back to gateway.
public IReadOnlyList<string> Nameservers { get; set; }
2.7. Password
Initial password applied to root + admin user (users.users.<name>.initialPassword). Defaults to the central NETSetup admin password so SSH key auth and console login both work with the same value across Windows/Nix/PMG provisioning.
public string Password { get; set; }
2.8. RecommendedCpuCores
Recommended runtime vCPU count. Default 2 (mail/dns/generic). Nextcloud overrides to 4 because php-fpm + nix-install closure builds saturate fewer cores.
public override uint RecommendedCpuCores { get; }
2.9. RecommendedDiskGib
Recommended VM disk size in GiB. Nextcloud needs ~256 (closure build space); dns/mail/pmg fit comfortably in 32. Default 32; concrete templates override.
public override int RecommendedDiskGib { get; }
2.10. RecommendedMemoryGib
Recommended runtime RAM in GiB. Default 8. Nextcloud and IPFS keep the same value explicitly (php-fpm / the ipfs daemon need the headroom at runtime as well).
public override int RecommendedMemoryGib { get; }
2.11. RecommendedSwapMib
Steady-state swapfile size in MiB written to /var/swapfile. Default 8192 (8 GiB). Tight RAM (Mail/Dns at 2 GiB) makes runtime OOM likely under load — swap is slow but keeps services alive. Nextcloud overrides to 16 GiB given larger working set.
public override int RecommendedSwapMib { get; }
2.12. StaticIPv4
Static IPv4 to assign to the primary NIC (e.g. "192.168.1.183"). Null/empty → DHCP.
public string StaticIPv4 { get; set; }
2.13. StaticIPv4Prefix
Static IPv4 prefix length when StaticIPv4 is set. Default /24.
public int StaticIPv4Prefix { get; set; }
2.14. TimeZone
IANA time zone.
public string TimeZone { get; set; }
2.15. UserName
Default admin user.
public string UserName { get; set; }
3. Methods
3.1. GenerateDefaultNix()
Host default.nix content. Concrete per template.
public override string GenerateDefaultNix()
Returns: string
3.2. GenerateFlakeNix()
flake.nix for this host.
public virtual string GenerateFlakeNix()
Returns: string
3.3. GenerateHardwareNix()
hardware.nix for this host.
public virtual string GenerateHardwareNix()
Returns: string
3.4. GenerateStaticNetworkBlock()
Returns the network nix snippet — ALWAYS emits host.system.network.dhcp.enable so individual templates must NOT repeat it (NixOS module eval treats duplicate attribute definitions within the same {} body as an "already defined" error, even when one is mkDefault and the other mkForce — priority modifiers only resolve cross-module conflicts, not intra-set duplicates). Emits the static-IPv4 block additionally when StaticIPv4 is set.
protected string GenerateStaticNetworkBlock()
Returns: string
3.5. GetRequiredSecrets(NETSetupConfig)
Extra sops secrets this template requires in the per-VM secrets.yaml (beyond the always-emitted luks password). Base returns none; concrete templates (e.g. NixIpfsTemplate) override to contribute nested/multiline entries.
public override IReadOnlyList<NixSecretEntry> GetRequiredSecrets(NETSetupConfig config)
| Name | Type | Description |
|---|---|---|
config |
NETSetupConfig |
Returns: IReadOnlyList<NixSecretEntry>