aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual/src')
-rw-r--r--doc/manual/src/language/advanced-attributes.md17
-rw-r--r--doc/manual/src/language/derivations.md5
2 files changed, 15 insertions, 7 deletions
diff --git a/doc/manual/src/language/advanced-attributes.md b/doc/manual/src/language/advanced-attributes.md
index 4907f7457..a5ad47a93 100644
--- a/doc/manual/src/language/advanced-attributes.md
+++ b/doc/manual/src/language/advanced-attributes.md
@@ -274,18 +274,21 @@ Derivations can declare some infrequently used optional attributes.
- [`__structuredAttrs`]{#adv-attr-structuredAttrs}\
If the special attribute `__structuredAttrs` is set to `true`, the other derivation
- attributes are serialised in JSON format and made available to the
- builder via the file `.attrs.json` in the builder’s temporary
- directory. This obviates the need for [`passAsFile`](#adv-attr-passAsFile) since JSON files
- have no size restrictions, unlike process environments.
+ attributes are serialised into a file in JSON format. The environment variable
+ `NIX_ATTRS_JSON_FILE` points to the exact location of that file both in a build
+ and a [`nix-shell`](../command-ref/nix-shell.md). This obviates the need for
+ [`passAsFile`](#adv-attr-passAsFile) since JSON files have no size restrictions,
+ unlike process environments.
It also makes it possible to tweak derivation settings in a structured way; see
[`outputChecks`](#adv-attr-outputChecks) for example.
As a convenience to Bash builders,
- Nix writes a script named `.attrs.sh` to the builder’s directory
- that initialises shell variables corresponding to all attributes
- that are representable in Bash. This includes non-nested
+ Nix writes a script that initialises shell variables
+ corresponding to all attributes that are representable in Bash. The
+ environment variable `NIX_ATTRS_SH_FILE` points to the exact
+ location of the script, both in a build and a
+ [`nix-shell`](../command-ref/nix-shell.md). This includes non-nested
(associative) arrays. For example, the attribute `hardening.format = true`
ends up as the Bash associative array element `${hardening[format]}`.
diff --git a/doc/manual/src/language/derivations.md b/doc/manual/src/language/derivations.md
index 79a09122a..e4a2fe714 100644
--- a/doc/manual/src/language/derivations.md
+++ b/doc/manual/src/language/derivations.md
@@ -123,6 +123,11 @@ The builder is executed as follows:
- `NIX_STORE` is set to the path of the top-level Nix store
directory (typically, `/nix/store`).
+
+ - `NIX_ATTRS_JSON_FILE` & `NIX_ATTRS_SH_FILE` if `__structuredAttrs`
+ is set to `true` for the dervation. A detailed explanation of this
+ behavior can be found in the
+ [section about structured attrs](./advanced-attributes.md#adv-attr-structuredAttrs).
- For each output declared in `outputs`, the corresponding
environment variable is set to point to the intended path in the