2023-03-23 17:27:41 +02:00
|
|
|
|
# Name
|
|
|
|
|
|
2023-07-19 14:30:40 +03:00
|
|
|
|
`nix-store --realise` - build or fetch store objects
|
2023-03-23 17:27:41 +02:00
|
|
|
|
|
|
|
|
|
# Synopsis
|
|
|
|
|
|
|
|
|
|
`nix-store` {`--realise` | `-r`} *paths…* [`--dry-run`]
|
|
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
|
|
|
|
|
|
2023-06-27 10:16:36 +03:00
|
|
|
|
Each of *paths* is processed as follows:
|
2023-05-03 16:36:13 +03:00
|
|
|
|
|
|
|
|
|
- If the path leads to a [store derivation]:
|
2023-07-19 10:31:03 +03:00
|
|
|
|
1. If it is not [valid], substitute the store derivation file itself.
|
2023-05-03 16:36:13 +03:00
|
|
|
|
2. Realise its [output paths]:
|
|
|
|
|
- Try to fetch from [substituters] the [store objects] associated with the output paths in the store derivation's [closure].
|
2023-09-26 01:39:11 +03:00
|
|
|
|
- With [content-addressed derivations] (experimental):
|
|
|
|
|
Determine the output paths to realise by querying content-addressed realisation entries in the [Nix database].
|
|
|
|
|
- For any store paths that cannot be substituted, produce the required store objects:
|
|
|
|
|
1. Realise all outputs of the derivation's dependencies
|
|
|
|
|
2. Run the derivation's [`builder`](@docroot@/language/derivations.md#attr-builder) executable
|
|
|
|
|
<!-- TODO: Link to build process page #8888 -->
|
2023-07-19 14:28:44 +03:00
|
|
|
|
- Otherwise, and if the path is not already valid: Try to fetch the associated [store objects] in the path's [closure] from [substituters].
|
2023-05-03 16:36:13 +03:00
|
|
|
|
|
|
|
|
|
If no substitutes are available and no store derivation is given, realisation fails.
|
|
|
|
|
|
2024-04-10 00:07:39 +03:00
|
|
|
|
[store paths]: @docroot@/store/store-path.md
|
2023-03-23 17:27:41 +02:00
|
|
|
|
[valid]: @docroot@/glossary.md#gloss-validity
|
2023-05-03 16:36:13 +03:00
|
|
|
|
[store derivation]: @docroot@/glossary.md#gloss-store-derivation
|
|
|
|
|
[output paths]: @docroot@/glossary.md#gloss-output-path
|
2024-04-10 00:07:39 +03:00
|
|
|
|
[store objects]: @docroot@/store/store-object.md
|
2023-05-03 16:36:13 +03:00
|
|
|
|
[closure]: @docroot@/glossary.md#gloss-closure
|
|
|
|
|
[substituters]: @docroot@/command-ref/conf-file.md#conf-substituters
|
|
|
|
|
[content-addressed derivations]: @docroot@/contributing/experimental-features.md#xp-feature-ca-derivations
|
|
|
|
|
[Nix database]: @docroot@/glossary.md#gloss-nix-database
|
|
|
|
|
|
|
|
|
|
The resulting paths are printed on standard output.
|
|
|
|
|
For non-derivation arguments, the argument itself is printed.
|
2023-03-23 17:27:41 +02:00
|
|
|
|
|
2023-05-03 16:36:13 +03:00
|
|
|
|
{{#include ../status-build-failure.md}}
|
2023-03-23 17:27:41 +02:00
|
|
|
|
|
2023-05-03 16:36:13 +03:00
|
|
|
|
# Options
|
2023-03-23 17:27:41 +02:00
|
|
|
|
|
|
|
|
|
- `--dry-run`\
|
|
|
|
|
Print on standard error a description of what packages would be
|
|
|
|
|
built or downloaded, without actually performing the operation.
|
|
|
|
|
|
|
|
|
|
- `--ignore-unknown`\
|
|
|
|
|
If a non-derivation path does not have a substitute, then silently
|
|
|
|
|
ignore it.
|
|
|
|
|
|
|
|
|
|
- `--check`\
|
|
|
|
|
This option allows you to check whether a derivation is
|
|
|
|
|
deterministic. It rebuilds the specified derivation and checks
|
|
|
|
|
whether the result is bitwise-identical with the existing outputs,
|
|
|
|
|
printing an error if that’s not the case. The outputs of the
|
|
|
|
|
specified derivation must already exist. When used with `-K`, if an
|
|
|
|
|
output path is not identical to the corresponding output from the
|
|
|
|
|
previous build, the new output path is left in
|
|
|
|
|
`/nix/store/name.check.`
|
|
|
|
|
|
|
|
|
|
{{#include ./opt-common.md}}
|
|
|
|
|
|
|
|
|
|
{{#include ../opt-common.md}}
|
|
|
|
|
|
|
|
|
|
{{#include ../env-common.md}}
|
|
|
|
|
|
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
This operation is typically used to build [store derivation]s produced by
|
|
|
|
|
[`nix-instantiate`](@docroot@/command-ref/nix-instantiate.md):
|
|
|
|
|
|
|
|
|
|
```console
|
2023-04-30 16:52:38 +03:00
|
|
|
|
$ nix-store --realise $(nix-instantiate ./test.nix)
|
2023-03-23 17:27:41 +02:00
|
|
|
|
/nix/store/31axcgrlbfsxzmfff1gyj1bf62hvkby2-aterm-2.3.1
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This is essentially what [`nix-build`](@docroot@/command-ref/nix-build.md) does.
|
|
|
|
|
|
|
|
|
|
To test whether a previously-built derivation is deterministic:
|
|
|
|
|
|
|
|
|
|
```console
|
2023-04-30 16:52:38 +03:00
|
|
|
|
$ nix-build '<nixpkgs>' --attr hello --check -K
|
2023-03-23 17:27:41 +02:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Use [`nix-store --read-log`](./read-log.md) to show the stderr and stdout of a build:
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
$ nix-store --read-log $(nix-instantiate ./test.nix)
|
|
|
|
|
```
|