Skip to main content

A *complete* listing of operators in Nix, and their predence.

This article was originally published at https://gist.github.com/joepie91/c3c047f3406aea9ec65eebce2ffd449d.

The information in this article has since been absorbed into the official Nix manual. It is kept here for posterity. It may be outdated by the time you read this.

Lower precedence means a stronger binding; ie. this list is sorted from strongest to weakest binding, and in the case of equal precedence between two operators, the associativity decides the binding.

PrecAbbreviationExampleAssocDescription
1SELECTe . attrpath [or def]noneSelect attribute denoted by the attribute path attrpath from set e. (An attribute path is a dot-separated list of attribute names.) If the attribute doesn’t exist, return default if provided, otherwise abort evaluation.
2APPe1 e2leftCall function e1 with argument e2.
3NEG-enoneNumeric negation.
4HAS_ATTRe ? attrpathnoneTest whether set e contains the attribute denoted by attrpath; return true or false.
5CONCATe1 ++ e2rightList concatenation.
6MULe1 * e2leftNumeric multiplication.
6DIVe1 / e2leftNumeric division.
7ADDe1 + e2leftNumeric addition, or string concatenation.
7SUBe1 - e2leftNumeric subtraction.
8NOT!eleftBoolean negation.
9UPDATEe1 // e2rightReturn a set consisting of the attributes in e1 and e2 (with the latter taking precedence over the former in case of equally named attributes).
10LTe1 < e2leftLess than.
10LTEe1 <= e2leftLess than or equal.
10GTe1 > e2leftGreater than.
10GTEe1 >= e2leftGreater than or equal.
11EQe1 == e2noneEquality.
11NEQe1 != e2noneInequality.
12ANDe1 && e2leftLogical AND.
13ORe1 || e2leftLogical OR.
14IMPLe1 -> e2noneLogical implication (equivalent to !e1 || e2).