Skip to content

Built-in Constants

These constants are built into the Nix language evaluator:

builtins (set)
Contains all the [built-in functions](../language/builtins.md) and values. 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:
## if hasContext is not available, we assume `s` has a context
if builtins ? hasContext then builtins.hasContext s else true
currentSystem (string)
The value of the [`eval-system`](../Command-Reference/conf-file.md#conf-eval-system) or else [`system`](../Command-Reference/conf-file.md#conf-system) configuration option. It can be used to set the `system` attribute for [`builtins.derivation`](../language/derivations.md) such that the resulting derivation can be built on the same system that evaluates the Nix expression:
 builtins.derivation {
   ## ...
   system = builtins.currentSystem;
}
It can be overridden in order to create derivations for different system than the current one:
$ nix-instantiate --system "mips64-linux" --eval --expr 'builtins.currentSystem'
"mips64-linux"
!!! note Not available in [pure evaluation mode](../Command-Reference/conf-file.md#conf-pure-eval).
currentTime (integer)
Return the [Unix time](https://en.wikipedia.org/wiki/Unix_time) at first evaluation. Repeated references to that name will re-use the initially obtained value. Example:
$ nix repl
Welcome to Nix 2.15.1 Type :? for help.

nix-repl> builtins.currentTime
1683705525

nix-repl> builtins.currentTime
1683705525
The [store path](../glossary.md#gloss-store-path) of a derivation depending on `currentTime` will differ for each evaluation, unless both evaluate `builtins.currentTime` in the same second. !!! note Not available in [pure evaluation mode](../Command-Reference/conf-file.md#conf-pure-eval).
false (Boolean)
Primitive value. It can be returned by [comparison operators](../language/operators.md#Comparison) and used in [conditional expressions](../language/constructs.md#Conditionals). The name `false` is not special, and can be shadowed:
nix-repl> let false = 1; in false
1
langVersion (integer)
The legacy version of the Nix language. Always is `6` on Lix, matching Nix 2.18. Code in the Nix language should use other means of feature detection like detecting the presence of builtins, rather than trying to find the version of the Nix implementation, as there may be other Nix implementations with different feature combinations. If the feature you want to write compatibility code for cannot be detected by any means, please file a Lix bug.
nixPath (list)
The search path used to resolve angle bracket path lookups. Angle bracket expressions can be [desugared](https://en.wikipedia.org/wiki/Syntactic_sugar) using this and [`builtins.findFile`](./builtins.html#builtins-findFile):
<nixpkgs>
is equivalent to:
builtins.findFile builtins.nixPath "nixpkgs"
nixVersion (string)
Legacy version of Nix. Always returns "2.18.3-lix" on Lix. Code in the Nix language should use other means of feature detection like detecting the presence of builtins, rather than trying to find the version of the Nix implementation, as there may be other Nix implementations with different feature combinations. If the feature you want to write compatibility code for cannot be detected by any means, please file a Lix bug.
null (null)
Primitive value. The name `null` is not special, and can be shadowed:
nix-repl> let null = 1; in null
1
storeDir (string)
Logical file system location of the [Nix store](../glossary.md#gloss-store) currently in use. This value is determined by the `store` parameter in [Store URLs](../Command-Reference/New-CLI/nix3-help-stores.md):
$ nix-instantiate --store 'dummy://?store=/blah' --eval --expr builtins.storeDir
"/blah"
true (Boolean)
Primitive value. It can be returned by [comparison operators](../language/operators.md#Comparison) and used in [conditional expressions](../language/constructs.md#Conditionals). The name `true` is not special, and can be shadowed:
nix-repl> let true = 1; in true
1

Things which might be mistaken for constants

__curPos
This is not a constant but a [context-dependent keyword](../language/constructs.md#keywords-__curPos)