Stolen Syntax: Difference between revisions

From NixOS Wiki
imported>Roberth
Say something about stolen syntax. I hope this is useful.
 
m Add a reasoning for the page name. Reasoning assumed from context here.
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:


This page presents a cross-section of well known "keywords" used in attribute sets in various components.
This page presents a cross-section of well known "keywords" used in attribute sets in various components.
Since neither the runtime, not the language reserve these keywords, these keywords are described ''stolen'' rather than ''reserved''.


== Nix language ==
== Nix language ==
Line 28: Line 30:
* _file
* _file
* ...
* ...
[[Category:Nix]]

Latest revision as of 23:50, 4 April 2024

The Nix language allows any name to be used in an attribute set, but Nix, some libraries, and the ecosystem in general assign special meaning to some names that appear in attribute sets that consist of otherwise freely named variables.

This page presents a cross-section of well known "keywords" used in attribute sets in various components.

Since neither the runtime, not the language reserve these keywords, these keywords are described stolen rather than reserved.

Nix language

  • outPath
  • __functor
  • __toString

nix-build

  • recurseForDerivations

The wider ecosystem

  • _type for nominal typing. Should contain a string. Pioneered by the module system (?)
  • ~type~ in principle this one is available for domain specific use! That is, unless you want the attrset to double as a "derivation" in the CLI.

Module system

  • _type
  • config, options (etc) (switches away from shorthand syntax)
  • _module option tree is omitted from the returned config and is intended for module system specific use
  • _key
  • _class
  • _file
  • ...