about summary refs log tree commit diff
path: root/nix/nix-1p
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-07-11T11·04+0300
committertazjin <tazjin@tvl.su>2023-08-01T19·53+0000
commit9f762bf623a17ae4292c3f0f00d9126cb195a0cb (patch)
tree6ca400dcbf7b6af9a89fc9d5031d292696ec69f1 /nix/nix-1p
parentf9fbc9be856aa6289672fe640c7f833c7550deda (diff)
docs(nix-1p): explain scope of `with` r/6459
This fixes https://github.com/tazjin/nix-1p/issues/13

Due to with's use of a semicolon instead of some kind of bracing
statement, people can get confused about what the scope of a `with`
is.

Hopefully this change should make it more explicit.

Change-Id: Ifaff28e09a2e8b8b244a9c11d44b2780dee284ee
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8951
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'nix/nix-1p')
-rw-r--r--nix/nix-1p/README.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/nix/nix-1p/README.md b/nix/nix-1p/README.md
index 18cbbcd201d0..48a20e6ba72a 100644
--- a/nix/nix-1p/README.md
+++ b/nix/nix-1p/README.md
@@ -326,6 +326,14 @@ let attrs = { a = 15; b = 2; };
 in with attrs; a + b # 'a' and 'b' become variables in the scope following 'with'
 ```
 
+The scope of a `with`-"block" is the expression immediately following the
+semicolon, i.e.:
+
+```nix
+let attrs = { /* some attributes */ };
+in with attrs; (/* this is the scope of the `with` */)
+```
+
 ## `import` / `NIX_PATH` / `<entry>`
 
 Nix files can import each other by using the builtin `import` function and a