|
4 | 4 |
|
5 | 5 | These values are mostly similar to JSON: |
6 | 6 |
|
7 | | -| Type | Description | Example |
8 | | -|---|---|---| |
9 | | -| integer | Whole number | 1 | |
10 | | -| float | Floating point number | 1.054 | |
11 | | -| string | UTF-8 string | "hello!" | |
12 | | -| path | File or url | ./default.nix | |
| 7 | +| Type | Description | Example |
| 8 | +|---------------|-----------------------|------------------| |
| 9 | +| integer | Whole number | 1 | |
| 10 | +| float | Floating point number | 1.054 | |
| 11 | +| string | UTF-8 string | "hello!" | |
| 12 | +| path | File or url | ./default.nix | |
| 13 | + |
| 14 | +And these are the collection: |
| 15 | +| Type | Description | Example |
| 16 | +|---------------|--------------------------|------------------| |
| 17 | +| list | Multi-type list | ["hello" 1] | |
| 18 | +| attribute set | Key value structure | {key = "value";} | |
13 | 19 |
|
14 | 20 | *NOTE*: Paths are special. They will be resolved relative to the file. |
15 | 21 | They must start with a "." or "/", similar to how they would be expressed in a shell. |
@@ -112,6 +118,30 @@ let expressions work similarly to how they work in Haskell. |
112 | 118 | sha256 = "..."; |
113 | 119 | }; |
114 | 120 | ``` |
| 121 | + |
| 122 | +## Inherit statements |
| 123 | + |
| 124 | +An inherit statement can be used to _pull_ values out of a parent scope |
| 125 | +into the current one. Values are whitespace separated and the statement |
| 126 | +ends with a `;`. |
| 127 | + |
| 128 | +If an attribute set in parenthesis follows immediately after the `inherit` |
| 129 | +keyword, then values can also be pulled directly out of the given set. |
| 130 | + |
| 131 | +In a `let` block, inherit statements can also come before the values they |
| 132 | +reference, so long as they are in the same block. |
| 133 | + |
| 134 | +``` |
| 135 | +let |
| 136 | + inherit (set.values) name version; |
| 137 | +
|
| 138 | + set.values = { |
| 139 | + name = "package"; |
| 140 | + version = "0.1.0"; |
| 141 | + }; |
| 142 | +in |
| 143 | +{ inherit name version; } |
| 144 | +``` |
115 | 145 |
|
116 | 146 | ## With expressions |
117 | 147 |
|
|
0 commit comments