NixValue
A value in the NixOS option tree. Recursive on purpose: the NixOS module system types option values as string / bool / int / list / attribute set, and the RFC 42 settings convention maps a service’s own configuration file 1:1 onto a freeform attribute set. A flat string dictionary cannot express that, so this mirrors the Nix value shapes instead.
|
Note
|
Raw(string) is the escape hatch for expressions that must NOT be quoted, such as pkgs.htop, lib.mkForce true or a path literal. Everything else is rendered with Nix quoting rules applied.
|
public sealed class NixValue
1. Methods
1.1. Bool(bool)
Nix boolean.
public static NixValue Bool(bool value)
| Name | Type | Description |
|---|---|---|
value |
bool |
Returns: NixValue
1.2. Int(long)
Nix integer.
public static NixValue Int(long value)
| Name | Type | Description |
|---|---|---|
value |
long |
Returns: NixValue
1.3. List(NixValue[])
Nix list.
public static NixValue List(params NixValue[] items)
| Name | Type | Description |
|---|---|---|
items |
NixValue[] |
Returns: NixValue
1.4. Raw(string)
Verbatim Nix expression, emitted unquoted (e.g. pkgs.htop).
public static NixValue Raw(string expression)
| Name | Type | Description |
|---|---|---|
expression |
string |
Returns: NixValue
1.5. Render(int)
Renders this value as Nix source at the given indentation depth.
public string Render(int indent = 0)
| Name | Type | Description |
|---|---|---|
indent |
int |
Indentation depth in two-space units. |
Returns: string — Nix source for the value, without a trailing semicolon.
1.6. Set(IEnumerable<KeyValuePair<string, NixValue>>)
Nix attribute set. Member order is preserved so emitted nix stays diff-stable.
public static NixValue Set(IEnumerable<KeyValuePair<string, NixValue>> members)
| Name | Type | Description |
|---|---|---|
members |
IEnumerable<KeyValuePair<string, NixValue>> |
Returns: NixValue
1.7. String(string)
Quoted Nix string.
public static NixValue String(string value)
| Name | Type | Description |
|---|---|---|
value |
string |
Returns: NixValue