Nix (language): Difference between revisions

imported>Malteneuss
m Improve with explanation
imported>Rovanion
Did some proofreading.
Line 57: Line 57:
''</SyntaxHighlight>
''</SyntaxHighlight>
|-
|-
| Integers || || <code>5</code>
| Integers || A whole number without fractional component. || <code>5</code>
|-
|-
| Floating-point numbers || Precision is limited || <code>1.2</code>
| Floating-point numbers || Decimal numbers. Precision is limited. || <code>1.2</code>
|-
|-
| Path || relative paths will become absolute when evaluated, paths must contain a slash. <code><nixpkgs/pkgs></code> is also possible and will resolve to the folder incl. subfolders in your NIX_PATH || <syntaxHighlight>./hello/world
| Path || Relative paths will become absolute when evaluated, paths must contain a slash. <code><nixpkgs/pkgs></code> is also possible and will resolve to the folder incl. subfolders in your NIX_PATH || <syntaxHighlight>./hello/world
> /abs/path/to/hello/world
> /abs/path/to/hello/world
</syntaxHighlight>
</syntaxHighlight>
Line 67: Line 67:
> /path/to/your/nixpkgs/lib</syntaxHighlight>
> /path/to/your/nixpkgs/lib</syntaxHighlight>
|-
|-
| URI || || <code>http://example.org/foo.tar.bz2</code>
| URI || Uniform Resource Identifiers || <code>http://example.org/foo.tar.bz2</code>
|-
|-
| Boolean ||  || <code>true</code>, <code>false</code>
| Boolean ||  || <code>true</code>, <code>false</code>
|-
|-
| Null || || <code>null</code>
| Null || A representation of nothing. || <code>null</code>
|-
|-
| Lists || items are separated by space, not comma. Each item can be a value of any other type || <syntaxHighlight lang=nix>[ 1 ./example.bin { hello="world"; }] </syntaxHighlight>
| Lists || Items are separated by space, not comma. Each item can be a value of any other type || <syntaxHighlight lang=nix>[ 1 ./example.bin { hello="world"; }] </syntaxHighlight>
|-
|-
| Sets || In other languages called <code>dicts</code>(py),<code>objects</code>(js) <code>hashes</code>(ruby), essentially a list of key-value pairs || <syntaxHighlight lang=nix>{ key1="value1";  key2="value2"; }</syntaxHighlight>
| Sets || In other languages called <code>dicts</code>(py),<code>objects</code>(js) <code>hashes</code>(ruby), essentially a list of key-value pairs || <syntaxHighlight lang=nix>{ key1="value1";  key2="value2"; }</syntaxHighlight>
Line 79: Line 79:
> "world"</syntaxHighlight>
> "world"</syntaxHighlight>
|-
|-
| Functions || see below || <code>pattern: body</code>
| Functions || See below. || <code>pattern: body</code>
|}
|}
A detailed description of all types can be found in [https://nixos.org/nix/manual/#ssec-values The Nix manual]
A detailed description of all types can be found in [https://nixos.org/nix/manual/#ssec-values The Nix manual]