add cross-references to pure evaluation mode

use consistent wording everywhere.
add some details on the configuration option documentation.
This commit is contained in:
Valentin Gagarin 2023-05-17 14:59:47 +02:00
parent 549f8dc97b
commit 6a5a8f51bb
5 changed files with 21 additions and 18 deletions

View file

@ -18,6 +18,8 @@ These constants are built into the Nix language evaluator:
identifier for the Nix installation on which the expression is being identifier for the Nix installation on which the expression is being
evaluated, such as `"i686-linux"` or `"x86_64-darwin"`. evaluated, such as `"i686-linux"` or `"x86_64-darwin"`.
Not available in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
- [`builtins.currentTime`]{#builtins-currentTime} (integer) - [`builtins.currentTime`]{#builtins-currentTime} (integer)
Return the [Unix time](https://en.wikipedia.org/wiki/Unix_time) at first evaluation. Return the [Unix time](https://en.wikipedia.org/wiki/Unix_time) at first evaluation.
@ -36,7 +38,6 @@ These constants are built into the Nix language evaluator:
1683705525 1683705525
``` ```
> **Warning** The [store path](@docroot@/glossary.md#gloss-store-path) of a derivation depending on `currentTime` will differ for each evaluation.
>
> This is intended for testing and debugging only. Not available in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
> Do not use it in production systems, since an impure, that is, non-constant value will break reproducibility.

View file

@ -745,7 +745,13 @@ struct EvalSettings : Config
)"}; )"};
Setting<bool> pureEval{this, false, "pure-eval", Setting<bool> pureEval{this, false, "pure-eval",
"Whether to restrict file system and network access to files specified by cryptographic hash."}; R"(
Pure evaluation mode ensures that the result of Nix expressions is fully determined by explicitly declared inputs, and not influenced by external state:
- Restrict file system and network access to files specified by cryptographic hash
- Disable [`bultins.currentSystem`](@docroot@/language/builtin-constants.md#builtins-currentSystem) and [`builtins.currentTime`](@docroot@/language/builtin-constants.md#builtins-currentTime)
)"
};
Setting<bool> enableImportFromDerivation{ Setting<bool> enableImportFromDerivation{
this, true, "allow-import-from-derivation", this, true, "allow-import-from-derivation",

View file

@ -1502,7 +1502,7 @@ static RegisterPrimOp primop_storePath({
causes the path to be *copied* again to the Nix store, resulting causes the path to be *copied* again to the Nix store, resulting
in a new path (e.g. `/nix/store/ld01dnzc-source-source`). in a new path (e.g. `/nix/store/ld01dnzc-source-source`).
This function is not available in pure evaluation mode. Not available in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
)", )",
.fun = prim_storePath, .fun = prim_storePath,
}); });

View file

@ -286,9 +286,9 @@ static RegisterPrimOp primop_fetchurl({
.name = "__fetchurl", .name = "__fetchurl",
.args = {"url"}, .args = {"url"},
.doc = R"( .doc = R"(
Download the specified URL and return the path of the downloaded Download the specified URL and return the path of the downloaded file.
file. This function is not available if [restricted evaluation
mode](../command-ref/conf-file.md) is enabled. Not available in [restricted evaluation mode](@docroot@/command-ref/conf-file.md#conf-restrict-eval).
)", )",
.fun = prim_fetchurl, .fun = prim_fetchurl,
}); });
@ -338,8 +338,7 @@ static RegisterPrimOp primop_fetchTarball({
stdenv.mkDerivation { } stdenv.mkDerivation { }
``` ```
This function is not available if [restricted evaluation Not available in [restricted evaluation mode](@docroot@/command-ref/conf-file.md#conf-restrict-eval).
mode](../command-ref/conf-file.md) is enabled.
)", )",
.fun = prim_fetchTarball, .fun = prim_fetchTarball,
}); });
@ -470,14 +469,9 @@ static RegisterPrimOp primop_fetchGit({
} }
``` ```
> **Note** Nix will refetch the branch according to the [`tarball-ttl`](@docroot@/command-ref/conf-file.md#conf-tarball-ttl) setting.
>
> Nix will refetch the branch in accordance with
> the option `tarball-ttl`.
> **Note** This behavior is disabled in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
>
> This behavior is disabled in *Pure evaluation mode*.
- To fetch the content of a checked-out work directory: - To fetch the content of a checked-out work directory:

View file

@ -50,6 +50,8 @@ constexpr std::array<ExperimentalFeatureDetails, 13> xpFeatureDetails = {{
or other impure derivations can rely on impure derivations. Finally, or other impure derivations can rely on impure derivations. Finally,
an impure derivation cannot also be an impure derivation cannot also be
[content-addressed](#xp-feature-ca-derivations). [content-addressed](#xp-feature-ca-derivations).
This is a more explicit alternative to using [`builtins.currentTime`](@docroot@/language/builtin-constants.md#builtins-currentTime).
)", )",
}, },
{ {