about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-07T15·08+0100
committerVincent Ambo <github@tazj.in>2019-08-07T15·36+0100
commit19d6d5a16ccbb4d6d38034d3d636180231018ba5 (patch)
tree8f5eafc34bcb508fb5e387c0f5140835597a0902
parentd113a91ae8b9d41a593a848305288cebd8f7955d (diff)
Add table with most important Nix operators
-rw-r--r--nix/nix-1p/README.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/nix/nix-1p/README.md b/nix/nix-1p/README.md
index 93d1c896b2..ef3e97ae1d 100644
--- a/nix/nix-1p/README.md
+++ b/nix/nix-1p/README.md
@@ -15,6 +15,7 @@ important is missing.
 - [Overview](#overview)
 - [Language constructs](#language-constructs)
     - [Primitives / literals](#primitives--literals)
+    - [Operators](#operators)
     - [Variable bindings](#variable-bindings)
     - [Functions](#functions)
         - [Multiple arguments (currying)](#multiple-arguments-currying)
@@ -104,6 +105,28 @@ second line
 rec { a = 15; b = a * 2; }
 ```
 
+## Operators
+
+Nix has several operators, most of which are unsurprising:
+
+| Syntax               | Description                                                                 |
+|----------------------|-----------------------------------------------------------------------------|
+| `+`, `-`, `*`, `/`   | Numerical operations                                                        |
+| `+`                  | String concatenation                                                        |
+| `++`                 | List concatenation                                                          |
+| `==`                 | Equality                                                                    |
+| `>`, `>=`, `<`, `<=` | Ordering comparators                                                        |
+| `&&`                 | Logical `AND`                                                               |
+| `\|\|`               | Logical `OR`                                                                |
+| `e1 -> e2`           | Logical implication (i.e. `!e1 \|\| e2`)                                    |
+| `!`                  | Boolean negation                                                            |
+| `set.attr`           | Access attribute `attr` in attribute set `set`                              |
+| `set ? attribute`    | Test whether attribute set contains an attribute                            |
+| `left // right`      | Merge `left` & `right` attribute sets, with the right set taking precedence |
+
+Make sure to understand the `//`-operator, as it is used quite a lot and is
+probably the least familiar one.
+
 ## Variable bindings
 
 Bindings in Nix are introduced locally via `let` expressions, which make some