Merge pull request #6846 from fricklerhandwerk/values

manual: use subheadings for primitive types
This commit is contained in:
Théophane Hufschmitt 2022-08-03 14:50:41 +02:00 committed by GitHub
commit 7d1ccd9105
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 155 additions and 147 deletions

View file

@ -34,7 +34,7 @@
- [Building and Testing](expressions/simple-building-testing.md)
- [Generic Builder Syntax](expressions/generic-builder.md)
- [Nix Expression Language](expressions/expression-language.md)
- [Values](expressions/language-values.md)
- [Data Types](expressions/language-values.md)
- [Language Constructs](expressions/language-constructs.md)
- [Operators](expressions/language-operators.md)
- [Derivations](expressions/derivations.md)

View file

@ -1,10 +1,10 @@
# Values
# Data Types
## Simple Values
## Primitives
Nix has the following basic data types:
- <a id="type-string" href="#type-string">String</a>
- *Strings* can be written in three ways.
*Strings* can be written in three ways.
The most common way is to enclose the string between double quotes,
e.g., `"foo bar"`. Strings can span multiple lines. The special
@ -112,14 +112,18 @@ Nix has the following basic data types:
`"http://example.org/foo.tar.bz2"` can also be written as
`http://example.org/foo.tar.bz2`.
- Numbers, which can be *integers* (like `123`) or *floating point*
- <a id="type-number" href="#type-number">Number</a>
Numbers, which can be *integers* (like `123`) or *floating point*
(like `123.43` or `.27e13`).
Numbers are type-compatible: pure integer operations will always
return integers, whereas any operation involving at least one
floating point number will have a floating point number as a result.
- *Paths*, e.g., `/bin/sh` or `./builder.sh`. A path must contain at
- <a id="type-path" href="#type-path">Path</a>
*Paths*, e.g., `/bin/sh` or `./builder.sh`. A path must contain at
least one slash to be recognised as such. For instance, `builder.sh`
is not a path: it's parsed as an expression that selects the
attribute `sh` from the variable `builder`. If the file name is
@ -146,11 +150,15 @@ Nix has the following basic data types:
recognized as a path. `a.${foo}/b.${bar}` is a syntactically valid division
operation. `./a.${foo}/b.${bar}` is a path.
- *Booleans* with values `true` and `false`.
- <a id="type-boolean" href="#type-boolean">Boolean</a>
- The null value, denoted as `null`.
*Booleans* with values `true` and `false`.
## Lists
- <a id="type-null" href="#type-null">Null</a>
The null value, denoted as `null`.
## List
Lists are formed by enclosing a whitespace-separated list of values
between square brackets. For example,
@ -172,9 +180,9 @@ function and the fifth being a set.
Note that lists are only lazy in values, and they are strict in length.
## Attribute Sets
## Attribute Set
Attribute sets are collections of name-value-pairs (called *attributes*) enclosed in curly brackets (`{ }`).
An attribute set is a collection of name-value-pairs (called *attributes*) enclosed in curly brackets (`{ }`).
Names and values are separated by an equal sign (`=`).
Each value is an arbitrary expression terminated by a semicolon (`;`).