Nix
To compute the store derivation path of an installable:
nix eval flake#output.drvPath
To actually make sure the store derivation is instantiated (and also return it):
nix path-info –derivation <installable>
The NixOS system flake output:
.#nixosConfigurations.chulak.config.system.build.toplevel
Getting the dependency tree of a derivation:
nix-store –query –tree <drv>
To get all the outputs of a derivation:'
nix path-info <installable>^*
To get the deriver that realised a store path:
nix-store –query –deriver <store path>
Finding why one derivation depends on another at runtime:
nix why-depends <dependant> <dependency>
Use –derivation for build-time dependencies of a derivation instead.
Unfortunately, nix why-depends seems to expect outputs as arguments, even when using –derivation.
nix-store –realise ¶
-
When given the path to a store derivation, the store derivation outputs get built or substituted
-
When given the path to not a store derivation, substitution of the path is attempted. It can’t be built because we have no idea what derivation is responsible for creating it.
The higher level frontend to this is
nix build
.nix-store --realise foo.drv
is equivalent tonix build foo.drv^*
nix-store --realise foo
is equivalent tonix build foo
Note that
nix build
will register and leave result symlinks, while nix-store will not.
Glossary ¶
- Installable: a flake output attribute, store path, nix file, or nix expression
- Store path: any paths in the Nix store, or symlinks thereto
- Store derivation: a compact representation of a derivation, stored as a .drv file in the store
- Output path: a store path produced by a derivation
- Deriver: the store derivation that produced an output path
- Instantiate: translate a derivation into a store derivation
- Realise: ensure a store path is valid by building or substituting it.