pub enum NixExpr {
Show 23 variants
Int(i64),
Float(f64),
Bool(bool),
Str(String),
Path(String),
Null,
List(Vec<NixExpr>),
AttrSet(Vec<NixAttr>),
Rec(Vec<NixAttr>),
With(Box<NixExpr>, Box<NixExpr>),
Let(Vec<NixLetBinding>, Box<NixExpr>),
If(Box<NixExpr>, Box<NixExpr>, Box<NixExpr>),
Lambda(Box<NixFunction>),
Apply(Box<NixExpr>, Box<NixExpr>),
Select(Box<NixExpr>, String, Option<Box<NixExpr>>),
Assert(Box<NixExpr>, Box<NixExpr>),
Var(String),
Inherit(Option<Box<NixExpr>>, Vec<String>),
Antiquote(String, Box<NixExpr>, String),
Multiline(String),
UnOp(String, Box<NixExpr>),
BinOp(String, Box<NixExpr>, Box<NixExpr>),
Import(Box<NixExpr>),
}Expand description
Nix expression AST.
Variants§
Int(i64)
Integer literal: 42
Float(f64)
Float literal: 3.14
Bool(bool)
Boolean literal: true / false
Str(String)
String literal: "hello, world"
Path(String)
Path literal: ./path/to/file or /absolute/path
Null
null
List(Vec<NixExpr>)
List literal: [ e1 e2 e3 ]
AttrSet(Vec<NixAttr>)
Attribute set: { a = 1; b = 2; }
Rec(Vec<NixAttr>)
Recursive attribute set: rec { a = 1; b = a + 1; }
With(Box<NixExpr>, Box<NixExpr>)
with expr; body — bring all attrs of expr into scope
Let(Vec<NixLetBinding>, Box<NixExpr>)
let bindings in body
If(Box<NixExpr>, Box<NixExpr>, Box<NixExpr>)
if cond then t else f
Lambda(Box<NixFunction>)
Function abstraction: pat: body
Apply(Box<NixExpr>, Box<NixExpr>)
Function application: f arg
Select(Box<NixExpr>, String, Option<Box<NixExpr>>)
Attribute selection: e.attr or e.attr or default
Assert(Box<NixExpr>, Box<NixExpr>)
assert cond; body
Var(String)
Variable reference: pkgs, lib.mkOption, etc.
Inherit(Option<Box<NixExpr>>, Vec<String>)
Inherit expression inside a set: inherit (src) a b;
Antiquote(String, Box<NixExpr>, String)
String interpolation antiquotation: "prefix ${expr} suffix"
Multiline(String)
Multi-line (indented) string: '' ... ''
UnOp(String, Box<NixExpr>)
Unary operator: !b, -n
BinOp(String, Box<NixExpr>, Box<NixExpr>)
Binary operator: a + b, a // b, a ++ b, a == b, etc.
Import(Box<NixExpr>)
builtins.import or any builtins.* call