Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Plain (Antiquoted)

Literal value in an Antiquoted node. Constructor of Antiquoted, polymorphic in the content type.

Definition

Plain v

Fields

FieldTypeDescription
contentsvThe literal value: Text in string parts, String node in DynamicKey

Description

Plain represents a literal value that is not an antiquotation. In a string like "hello ${world}", the "hello " part is a Plain node with text content.

When used inside DynamicKey (as Antiquoted String), Plain wraps a String AST node (DoubleQuoted / Indented) instead of plain text. Use mkPlain for this case.

Nix Source ↔ AST

Antiquoted Text (string parts)

# Nix
"hello "

# AST (part of DoubleQuoted contents)
{ "tag": "Plain", "contents": "hello " }

Antiquoted String (DynamicKey)

# Nix
{ "foo bar" = 1; }

# AST (part of DynamicKey contents)
{ "tag": "Plain", "contents": { "tag": "DoubleQuoted", "contents": [...] } }

Nix Library Access

syntax.mkPlain "hello "       # text content (string parts)
syntax.mkPlain (syntax.mkDoubleQuoted [...])  # String node content (DynamicKey)