mirror of
https://github.com/NixOS/nix
synced 2025-07-10 04:43:53 +02:00
* A new primop `builtins', which returns an attribute set containing
all the primops. This allows Nix expressions to test for new primops and take appropriate action if they're not available. For instance, rather than calling a primop `foo' directly, they could say `if builtins ? foo then builtins.foo ... else ...'.
This commit is contained in:
parent
68515b5a96
commit
4a053bfdfd
3 changed files with 39 additions and 0 deletions
1
tests/lang/eval-okay-builtins.exp
Normal file
1
tests/lang/eval-okay-builtins.exp
Normal file
|
@ -0,0 +1 @@
|
|||
Path("/foo")
|
12
tests/lang/eval-okay-builtins.nix
Normal file
12
tests/lang/eval-okay-builtins.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
assert builtins ? currentSystem;
|
||||
assert !builtins ? __currentSystem;
|
||||
|
||||
let {
|
||||
|
||||
x = if builtins ? dirOf then builtins.dirOf /foo/bar else "";
|
||||
|
||||
y = if builtins ? fnord then builtins.fnord "foo" else "";
|
||||
|
||||
body = x + y;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue