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

StaticKey (Static Attribute Key)

Definition

StaticKey VarName

Fields

FieldTypeDescription
contentsVarNameThe identifier name

Description

StaticKey is used for bare identifier keys in attribute sets: keys that are valid Nix identifiers (alphanumeric + underscore, not starting with a digit). These are written without quotes.

{ foo = 1; bar = 2; }  -- both are StaticKey

Nix Source ↔ AST

# Nix
{ foo = 1; }

# AST (key part)
{ "tag": "StaticKey", "contents": "foo" }

Rules

  • Must be a valid Nix identifier: [a-zA-Z_][a-zA-Z0-9_]*
  • Cannot start with a digit
  • Cannot contain spaces or special characters (those require DynamicKey)

Nix Library Access

syntax.mkStaticKey "foo"
syntax.mkStaticKey "my_var_123"