mirror of
https://github.com/NixOS/nix.git
synced 2025-11-18 00:12:43 +01:00
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
54d684e1de
commit
094d352847
1 changed files with 15 additions and 29 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
# Store Derivation and Deriving Path
|
# Store Derivation and Deriving Path
|
||||||
|
|
||||||
So far, we have covered "inert" [store objects][store object].
|
Besides functioning as a [content addressed store] the Nix store layer works as a [build system].
|
||||||
But the point of the Nix store layer is to be a build system.
|
|
||||||
Other system (like Git or IPFS) also store and transfer immutable data, but they don't concern themselves with *how* that data was created.
|
Other system (like Git or IPFS) also store and transfer immutable data, but they don't concern themselves with *how* that data was created.
|
||||||
|
|
||||||
This is where Nix distinguishes itself.
|
This is where Nix distinguishes itself.
|
||||||
|
|
@ -12,11 +11,6 @@ This is where Nix distinguishes itself.
|
||||||
|
|
||||||
A derivation is a specification for running an executable on precisely defined input files to repeatably produce output files at uniquely determined file system paths.
|
A derivation is a specification for running an executable on precisely defined input files to repeatably produce output files at uniquely determined file system paths.
|
||||||
|
|
||||||
What is the natural Unix analog for a build step *in action*?
|
|
||||||
Answer: a process that will eventually exit, leaving behind some output files.
|
|
||||||
What is the natural way to *plan* such a step?
|
|
||||||
An `execve` system call.
|
|
||||||
|
|
||||||
A derivation consists of:
|
A derivation consists of:
|
||||||
|
|
||||||
- A name
|
- A name
|
||||||
|
|
@ -25,16 +19,9 @@ A derivation consists of:
|
||||||
|
|
||||||
- A map of [*outputs*][outputs], from names to other data
|
- A map of [*outputs*][outputs], from names to other data
|
||||||
|
|
||||||
- The [process creation fields]: to spawn the arbitrary process which will perform the build step:
|
- The ["system" type][system] (e.g. `x86_64-linux`) where the executable is to run.
|
||||||
|
|
||||||
|
- The [process creation fields]: to spawn the arbitrary process which will perform the build step.
|
||||||
- The [*builder*][builder], a path to an executable
|
|
||||||
|
|
||||||
- A list of [arguments][args]
|
|
||||||
|
|
||||||
- A map of [environment variables][env].
|
|
||||||
|
|
||||||
- A two-component ["system" type][system] (e.g. `x86_64-linux`) where the executable is to run.
|
|
||||||
|
|
||||||
[store derivation]: #store-derivation
|
[store derivation]: #store-derivation
|
||||||
[inputs]: #inputs
|
[inputs]: #inputs
|
||||||
|
|
@ -56,8 +43,7 @@ The store path of the store object which encodes a derivation is often called a
|
||||||
|
|
||||||
## Deriving path {#deriving-path}
|
## Deriving path {#deriving-path}
|
||||||
|
|
||||||
Deriving paths are a way to refer to [store objects][store object] that might not yet be [realised][realise].
|
Deriving paths are a way to refer to [store objects][store object] that may or may not yet be [realised][realise].
|
||||||
This is necessary because, in general and particularly for [content-addressed derivations][content-addressed derivation], the [store path] of an [output] is not known in advance.
|
|
||||||
There are two forms:
|
There are two forms:
|
||||||
|
|
||||||
- [*constant*]{#deriving-path-constant}: just a [store path].
|
- [*constant*]{#deriving-path-constant}: just a [store path].
|
||||||
|
|
@ -67,24 +53,24 @@ There are two forms:
|
||||||
|
|
||||||
In pseudo code:
|
In pseudo code:
|
||||||
|
|
||||||
```idris
|
```typescript
|
||||||
type OutputName = String
|
type OutputName = String;
|
||||||
|
|
||||||
data DerivingPath
|
type ConstantPath = { path: StorePath; }
|
||||||
= Constant { path : StorePath }
|
type OutputPath = { drvPath: StorePath; output: OutputName; }
|
||||||
| Output {
|
|
||||||
drvPath : StorePath,
|
type DerivingPath = ConstantPath | OutputPath
|
||||||
output : OutputName,
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Deriving paths are necessary because, in general and particularly for [content-addressed derivations][content-addressed derivation], the [store path] of an [output] is not known in advance.
|
||||||
|
We can use an output deriving path to refer to such an out, instead of the store path which we do not yet know.
|
||||||
|
|
||||||
[deriving path]: #deriving-path
|
[deriving path]: #deriving-path
|
||||||
[validity]: @docroot@/glossary.md#gloss-validity
|
[validity]: @docroot@/glossary.md#gloss-validity
|
||||||
|
|
||||||
## Parts of a derivation
|
## Parts of a derivation
|
||||||
|
|
||||||
With both [store derivations][store derivation] introduced and [deriving paths][deriving path] defined,
|
A derivation is constructed from the parts documented in the following subsections.
|
||||||
it is now possible to define the parts of a derivation.
|
|
||||||
|
|
||||||
### Inputs {#inputs}
|
### Inputs {#inputs}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue