diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-08-25 14:06:01 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-08-25 14:06:01 +0200 |
commit | 7a02865b94f107de1c1ef797b89d45ecd3f01cf1 (patch) | |
tree | 8262f1c7aba5870569a9ed7ffd20e53723287b51 /doc | |
parent | f53b5f10585b1d4c939e45faf0dd2f4dacbca013 (diff) |
Move import docs
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/src/expressions/builtins-prefix.md | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/doc/manual/src/expressions/builtins-prefix.md b/doc/manual/src/expressions/builtins-prefix.md index ae3bb150c..0f7c3d32f 100644 --- a/doc/manual/src/expressions/builtins-prefix.md +++ b/doc/manual/src/expressions/builtins-prefix.md @@ -13,56 +13,3 @@ For instance, `derivation` is also available as `builtins.derivation`. `derivation` is described in [its own section](derivations.md). - - `import` *path*; `builtins.import` *path* - - Load, parse and return the Nix expression in the file *path*. If - *path* is a directory, the file ` default.nix ` in that directory - is loaded. Evaluation aborts if the file doesn’t exist or contains - an incorrect Nix expression. `import` implements Nix’s module - system: you can put any Nix expression (such as a set or a - function) in a separate file, and use it from Nix expressions in - other files. - - > **Note** - > - > Unlike some languages, `import` is a regular function in Nix. - > Paths using the angle bracket syntax (e.g., `import` *\<foo\>*) - > are [normal path values](language-values.md). - - A Nix expression loaded by `import` must not contain any *free - variables* (identifiers that are not defined in the Nix expression - itself and are not built-in). Therefore, it cannot refer to - variables that are in scope at the call site. For instance, if you - have a calling expression - - ```nix - rec { - x = 123; - y = import ./foo.nix; - } - ``` - - then the following `foo.nix` will give an error: - - ```nix - x + 456 - ``` - - since `x` is not in scope in `foo.nix`. If you want `x` to be - available in `foo.nix`, you should pass it as a function argument: - - ```nix - rec { - x = 123; - y = import ./foo.nix x; - } - ``` - - and - - ```nix - x: x + 456 - ``` - - (The function argument doesn’t have to be called `x` in `foo.nix`; - any name would work.) |