reword example for clarity

This commit is contained in:
Valentin Gagarin 2023-09-26 00:58:50 +02:00
parent 7de66f19f8
commit 5b0336b3b1

View file

@ -71,11 +71,15 @@ It outputs an attribute set, and produces a [store derivation](@docroot@/glossar
Examples:
Imagine a library package that provides a dynamic library, header files, and documentation.
A program that links against the library doesnt need the header files and documentation at runtime, and it doesnt need the documentation at build time.
A program that links against such a library doesnt need the header files and documentation at runtime, and it doesnt need the documentation at build time.
Thus, the library package could specify:
```nix
derivation {
# ...
outputs = [ "lib" "dev" "doc" ];
# ...
}
```
This will cause Nix to pass environment variables `lib`, `dev`, and `doc` to the builder containing the intended store paths of each output.
@ -90,22 +94,12 @@ It outputs an attribute set, and produces a [store derivation](@docroot@/glossar
for an Autoconf-style package.
You can refer to each output of a
derivation by selecting it as an attribute, e.g.
```nix
buildInputs = [ pkg.lib pkg.dev ];
```
<!-- FIXME: move this to the output attributes section when we have one -->
You can refer to each output of a derivation by selecting it as an attribute, e.g. `myPackage.lib` or `myPackage.doc`.
The first element of `outputs` determines the *default output*.
Thus, you could also write
Therefore, in the given example, `myPackage` is equivalent to `myPackage.lib`.
```nix
buildInputs = [ pkg pkg.dev ];
```
since `pkg` is equivalent to `pkg.lib`.
<!-- FIXME: refer to the output attributes when we have one -->
- See [Advanced Attributes](./advanced-attributes.md) for more, infrequently used, optional attributes.