Merge pull request #8314 from fricklerhandwerk/doc-builtins
reword documentation on `builtins`
This commit is contained in:
commit
491fabda49
|
@ -1,20 +1,19 @@
|
||||||
# Built-in Constants
|
# Built-in Constants
|
||||||
|
|
||||||
Here are the constants built into the Nix expression evaluator:
|
These constants are built into the Nix language evaluator:
|
||||||
|
|
||||||
- `builtins`\
|
- [`builtins`]{#builtins-builtins} (attribute set)
|
||||||
The set `builtins` contains all the built-in functions and values.
|
|
||||||
You can use `builtins` to test for the availability of features in
|
|
||||||
the Nix installation, e.g.,
|
|
||||||
|
|
||||||
```nix
|
|
||||||
if builtins ? getEnv then builtins.getEnv "PATH" else ""
|
|
||||||
```
|
|
||||||
|
|
||||||
This allows a Nix expression to fall back gracefully on older Nix
|
|
||||||
installations that don’t have the desired built-in function.
|
|
||||||
|
|
||||||
- [`builtins.currentSystem`]{#builtins-currentSystem}\
|
Contains all the [built-in functions](./builtins.md) and values, in order to avoid polluting the global scope.
|
||||||
The built-in value `currentSystem` evaluates to the Nix platform
|
|
||||||
identifier for the Nix installation on which the expression is being
|
Since built-in functions were added over time, [testing for attributes](./operators.md#has-attribute) in `builtins` can be used for graceful fallback on older Nix installations:
|
||||||
evaluated, such as `"i686-linux"` or `"x86_64-darwin"`.
|
|
||||||
|
```nix
|
||||||
|
if builtins ? getEnv then builtins.getEnv "PATH" else ""
|
||||||
|
```
|
||||||
|
|
||||||
|
- [`builtins.currentSystem`]{#builtins-currentSystem} (string)
|
||||||
|
|
||||||
|
The built-in value `currentSystem` evaluates to the Nix platform
|
||||||
|
identifier for the Nix installation on which the expression is being
|
||||||
|
evaluated, such as `"i686-linux"` or `"x86_64-darwin"`.
|
||||||
|
|
Loading…
Reference in a new issue