Nix sets
The set is the fundamental data structure in Nix. Derivations are really just sets of attributes passed into build scripts. A set is a list of key-value pairs (attributes) enclosed in curly braces with each attribute terminated by a semicolon.
Attributes can have arbitrary strings as keys.
Examples
example = {
x = 123;
"greet me" = "hello";
${foo} = true;
inherit perl;
}
Fetching attributes
Attributes of a set can be accessed with the .
operator. That is, example."greet me"
evaluates to "hello"
. If foo
is antiquotable, its value will be true
, otherwise it will be omitted during evaluation.
We can use the or keywordᛦ to provide a default value.