docs(nix-1p): import is a builtin, not a keyword
Pointed out by @Gaelan on GH in https://github.com/tazjin/nix-1p/issues/12 As noted there, some Nix syntax highlighters will colour `import` differently (e.g. the Emacs nix-mode), but it's not technically a keyword in the language. Change-Id: I1bbd36261cda31deb9ba47380a2810e64ba03ea1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8832 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
ad687ccaf4
commit
09486d483c
1 changed files with 4 additions and 2 deletions
|
@ -325,8 +325,8 @@ in with attrs; a + b # 'a' and 'b' become variables in the scope following 'with
|
|||
|
||||
## `import` / `NIX_PATH` / `<entry>`
|
||||
|
||||
Nix files can import each other by using the `import` keyword and a literal
|
||||
path:
|
||||
Nix files can import each other by using the builtin `import` function and a
|
||||
literal path:
|
||||
|
||||
```nix
|
||||
# assuming there is a file lib.nix with some useful functions
|
||||
|
@ -334,6 +334,8 @@ let myLib = import ./lib.nix;
|
|||
in myLib.usefulFunction 42
|
||||
```
|
||||
|
||||
The `import` function will read and evaluate the file, and return its Nix value.
|
||||
|
||||
Nix files often begin with a function header to pass parameters into the rest of
|
||||
the file, so you will often see imports of the form `import ./some-file { ... }`.
|
||||
|
||||
|
|
Loading…
Reference in a new issue