diff --git a/doc/manual/src/language/import-from-derivation.md b/doc/manual/src/language/import-from-derivation.md index dedfc6ba139..8423ed22188 100644 --- a/doc/manual/src/language/import-from-derivation.md +++ b/doc/manual/src/language/import-from-derivation.md @@ -25,33 +25,33 @@ Building during evaluation can be disabled by setting [`allow-import-from-deriva ## Example -In the following Nix expression, the derivation `drv` produces a file containing `1` after `sleep`ing for 5 seconds. - -Since `1` is a valid Nix expression itself, it can be [`import`](./builtins.md#builtins-import)ed. -That requires reading from the output [store path] of `drv`, which has to be [realise]d before its contents `1` can be evaluated. - -[store path]: ../glossary.md#gloss-store-path +In the following Nix expression, the inner derivation `drv` produces a file containing `"hello"`. ```nix # IFD.nix let drv = derivation { - name = "expensive"; + name = "hello"; builder = /bin/sh; - args = [ "-c" "${/bin/sleep} 5; echo 1 > $out" ]; + args = [ "-c" "echo \"hello\" > $out" ]; system = builtins.currentSystem; }; -in import drv +in "${import drv} world" ``` ```shellSession nix-instantiate IFD.nix --eval --read-write-mode ``` - building '/nix/store/6n1mbib4n8l35ncfrbk8g8b3y14c7bi7-expensive.drv'... - 1 + building '/nix/store/348q1cal6sdgfxs8zqi9v8llrsn4kqkq-hello.drv'... + "hello world" +Since `"hello"` is a valid Nix expression, it can be [`import`](./builtins.md#builtins-import)ed. +That requires reading from the output [store path] of `drv`, which has to be [realise]d before its contents can be read and evaluated. + +[store path]: ../glossary.md#gloss-store-path + ## Illustration The following diagram shows how evaluation is interrupted by a build, if the value of a Nix expression specifying a derivation depends on the result of another derivation.