Derivation
- 1. Property
name - 2. Property
version - 3. Property
outputs - 4. Property
inputs - 5. Property
system - 6. Property
builder - 7. Property
args - 8. Property
env - 9. Property
structuredAttrs
Title: Derivation
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
Description: Experimental JSON representation of a Nix derivation (version 4).
This schema describes the JSON representation of Nix's Derivation type.
Warning
This JSON format is currently experimental and subject to change.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| + name | string | No | Derivation name |
| + version | const | No | Format version (must be 4) |
| + outputs | object | No | Output specifications |
| + inputs | object | No | Derivation inputs |
| + system | string | No | Build system type |
| + builder | string | No | Build program path |
| + args | array of string | No | Builder arguments |
| + env | object | No | Environment variables |
| - structuredAttrs | object | No | Structured attributes |
1. Property name
Title: Derivation name
| Type | string |
| Required | Yes |
Description: The name of the derivation. Used when calculating store paths for the derivation’s outputs.
2. Property version
Title: Format version (must be 4)
| Type | const |
| Required | Yes |
Description: Must be 4.
This is a guard that allows us to continue evolving this format.
The choice of 3 is fairly arbitrary, but corresponds to this informal version:
-
Version 0: ATerm format
-
Version 1: Original JSON format, with ugly
"r:sha256"inherited from ATerm format. -
Version 2: Separate
methodandhashAlgofields in output specs -
Version 3: Drop store dir from store paths, just include base name.
-
Version 4: Two cleanups, batched together to lesson churn:
-
Reorganize inputs into nested structure (
inputs.srcsandinputs.drvs) -
Use canonical content address JSON format for floating content addressed derivation outputs.
-
Note that while this format is experimental, the maintenance of versions is best-effort, and not promised to identify every change.
Specific value: 4
3. Property outputs
Title: Output specifications
| Type | object |
| Required | Yes |
| Additional properties | Each additional property must conform to the schema |
Description: Information about the output paths of the derivation. This is a JSON object with one member per output, where the key is the output name and the value is a JSON object as described.
Example
"outputs": { "out": { "method": "nar", "hashAlgo": "sha256", "hash": "6fc80dcc62179dbc12fc0b5881275898f93444833d21b89dfe5f7fbcbb1d0d62" } }
3.1. Property Derivation Output
Title: Derivation Output
| Type | combining |
| Required | No |
| Additional properties | Any type allowed |
| Defined in | #/$defs/output/overall |
Description: A single output of a derivation, with different variants for different output types.
| One of(Option) |
|---|
| Input-Addressed Output |
| Fixed Content-Addressed Output |
| Floating Content-Addressed Output |
| Deferred Output |
| Impure Output |
3.1.1. Property Input-Addressed Output
Title: Input-Addressed Output
| Type | object |
| Required | No |
| Additional properties | Not allowed |
| Defined in | #/$defs/output/inputAddressed |
Description: The traditional non-fixed-output derivation type. The output path is determined from the derivation itself.
See Input-addressing derivation outputs for more details.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| + path | string | No | Output path |
3.1.1.1. Property path
Title: Output path
| Type | string |
| Required | Yes |
| Defined in | store-path-v1.yaml |
Description: The output path determined from the derivation itself.
| Restrictions | |
|---|---|
| Min length | 34 |
| Must match regular expression | ^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+$ Test |
3.1.2. Property Fixed Content-Addressed Output
Title: Fixed Content-Addressed Output
| Type | object |
| Required | No |
| Additional properties | Not allowed |
| Defined in | #/$defs/output/caFixed |
Description: The output is content-addressed, and the content-address is fixed in advance.
See Fixed-output content-addressing for more details.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| + method | enum (of string) | No | Content-Addressing Method |
| + hash | string | No | Expected hash value |
3.1.2.1. Property method
Title: Content-Addressing Method
| Type | enum (of string) |
| Required | Yes |
| Defined in | JSON format for ContentAddress |
Description: Method of content addressing used for this output.
Must be one of:
- "flat"
- "nar"
- "text"
- "git"
3.1.2.2. Property hash
Title: Expected hash value
| Type | string |
| Required | Yes |
| Defined in | JSON format for Hash |
Description: The expected content hash.
Examples:
"sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="
"sha512-IEqPxt2oLwoM7XvrjgikFlfBbvRosiioJ5vjMacDwzWW/RXBOxsH+aodO+pXeJygMa2Fx6cd1wNU7GMSOMo0RQ=="
| Restrictions | |
|---|---|
| Must match regular expression | ^(blake3|md5|sha1|sha256|sha512)-[A-Za-z0-9+/]+=*$ Test |
3.1.3. Property Floating Content-Addressed Output
Title: Floating Content-Addressed Output
| Type | object |
| Required | No |
| Additional properties | Not allowed |
| Defined in | #/$defs/output/caFloating |
Description: Floating-output derivations, whose outputs are content addressed, but not fixed, and so the output paths are dynamically calculated from whatever the output ends up being.
See Floating Content-Addressing for more details.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| + method | enum (of string) | No | Content-Addressing Method |
| + hashAlgo | enum (of string) | No | Hash algorithm |
3.1.3.1. Property method
Title: Content-Addressing Method
| Type | enum (of string) |
| Required | Yes |
| Same definition as | method |
Description: Method of content addressing used for this output.
3.1.3.2. Property hashAlgo
Title: Hash algorithm
| Type | enum (of string) |
| Required | Yes |
| Defined in | JSON format for Hash |
Description: What hash algorithm to use for the given method of content-addressing.
Must be one of:
- "blake3"
- "md5"
- "sha1"
- "sha256"
- "sha512"
3.1.4. Property Deferred Output
Title: Deferred Output
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Defined in | #/$defs/output/deferred |
Description: Input-addressed output which depends on a (CA) derivation whose outputs (and thus their content-address are not yet known.
3.1.5. Property Impure Output
Title: Impure Output
| Type | object |
| Required | No |
| Additional properties | Not allowed |
| Defined in | #/$defs/output/impure |
Description: Impure output which is just like a floating content-addressed output, but this derivation runs without sandboxing. As such, we don't record it in the build trace, under the assumption that if we need it again, we should rebuild it, as it might produce something different.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| + impure | const | No | - |
| + method | enum (of string) | No | Content-Addressing Method |
| + hashAlgo | enum (of string) | No | Hash algorithm |
3.1.5.1. Property impure
| Type | const |
| Required | Yes |
Specific value: true
3.1.5.2. Property method
Title: Content-Addressing Method
| Type | enum (of string) |
| Required | Yes |
| Same definition as | method |
Description: How the file system objects will be serialized for hashing.
3.1.5.3. Property hashAlgo
Title: Hash algorithm
| Type | enum (of string) |
| Required | Yes |
| Defined in | JSON format for Hash |
Description: How the serialization will be hashed.
Must be one of:
- "blake3"
- "md5"
- "sha1"
- "sha256"
- "sha512"
4. Property inputs
Title: Derivation inputs
| Type | object |
| Required | Yes |
| Additional properties | Not allowed |
Description: Input dependencies for the derivation, organized into source paths and derivation dependencies.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| + srcs | array | No | Input source paths |
| + drvs | object | No | Input derivations |
4.1. Property srcs
Title: Input source paths
| Type | array |
| Required | Yes |
Description: List of store paths on which this derivation depends.
Example
"srcs": [ "47y241wqdhac3jm5l7nv0x4975mb1975-separate-debug-info.sh", "56d0w71pjj9bdr363ym3wj1zkwyqq97j-fix-pop-var-context-error.patch" ]
| Array restrictions | |
|---|---|
| Min items | N/A |
| Max items | N/A |
| Items unicity | False |
| Additional items | False |
| Tuple validation | See below |
| Each item of this array must be | Description |
|---|---|
| Store Path | A store path identifying a store object. ... |
4.1.1. Store Path
Title: Store Path
| Type | string |
| Required | No |
| Same definition as | path |
Description: A store path identifying a store object.
This schema describes the JSON representation of store paths as used in various Nix JSON APIs.
Format
Store paths in JSON are represented as strings containing just the hash and name portion, without the store directory prefix.
For example: "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"
(If the store dir is /nix/store, then this corresponds to the path /nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv.)
Structure
The format follows this pattern: ${digest}-${name}
- hash: Digest rendered in a custom variant of Base32 (20 arbitrary bytes become 32 ASCII characters)
- name: The package name and optional version/suffix information
4.2. Property drvs
Title: Input derivations
| Type | object |
| Required | Yes |
| Additional properties | Not allowed |
Description: Mapping of derivation paths to lists of output names they provide.
Example
"drvs": { "6lkh5yi7nlb7l6dr8fljlli5zfd9hq58-curl-7.73.0.drv": ["dev"], "fn3kgnfzl5dzym26j8g907gq3kbm8bfh-unzip-6.0.drv": ["out"] }specifies that this derivation depends on the
devoutput ofcurl, and theoutoutput ofunzip.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| - ^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+.drv$ | Combination | Yes | Store Path |
4.2.1. Pattern Property Store Path
All properties whose name matches the regular expression
^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+\.drv$(Test) must respect the following conditions
Title: Store Path
| Type | combining |
| Required | No |
| Additional properties | Any type allowed |
Description: A store path to a derivation, mapped to the outputs of that derivation.
| One of(Option) |
|---|
| Output Names |
| Dynamic Outputs |
4.2.1.1. Property Output Names
Title: Output Names
| Type | array |
| Required | No |
| Defined in | #/$defs/outputNames |
Description: Set of names of derivation outputs to depend on
| Array restrictions | |
|---|---|
| Min items | N/A |
| Max items | N/A |
| Items unicity | False |
| Additional items | False |
| Tuple validation | See below |
| Each item of this array must be | Description |
|---|---|
| Output name | Name of the derivation output to depend on |
4.2.1.1.1. Output name
Title: Output name
| Type | string |
| Required | No |
| Defined in | #/$defs/outputName |
Description: Name of the derivation output to depend on
4.2.1.2. Property Dynamic Outputs
Title: Dynamic Outputs
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Defined in | #/$defs/dynamicOutputs |
Description: Experimental feature: dynamic-derivations
This recursive data type allows for depending on outputs of outputs.
| Property | Type | Pattern | Title/Description |
|---|---|---|---|
| - outputs | array | No | Output Names |
| - dynamicOutputs | object | No | Dynamic Outputs |
4.2.1.2.1. Property outputs
Title: Output Names
| Type | array |
| Required | No |
| Same definition as | Output Names |
Description: Set of names of derivation outputs to depend on
4.2.1.2.2. Property dynamicOutputs
Title: Dynamic Outputs
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
| Same definition as | Dynamic Outputs |
Description: Experimental feature: dynamic-derivations
This recursive data type allows for depending on outputs of outputs.
5. Property system
Title: Build system type
| Type | string |
| Required | Yes |
Description: The system type on which this derivation is to be built
(e.g. x86_64-linux).
6. Property builder
Title: Build program path
| Type | string |
| Required | Yes |
Description: Absolute path of the program used to perform the build.
Typically this is the bash shell
(e.g. /nix/store/r3j288vpmczbl500w6zz89gyfa4nr0b1-bash-4.4-p23/bin/bash).
7. Property args
Title: Builder arguments
| Type | array of string |
| Required | Yes |
Description: Command-line arguments passed to the builder.
| Array restrictions | |
|---|---|
| Min items | N/A |
| Max items | N/A |
| Items unicity | False |
| Additional items | False |
| Tuple validation | See below |
| Each item of this array must be | Description |
|---|---|
| args items | - |
7.1. args items
| Type | string |
| Required | No |
8. Property env
Title: Environment variables
| Type | object |
| Required | Yes |
| Additional properties | Each additional property must conform to the schema |
Description: Environment variables passed to the builder.
8.1. Property additionalProperties
| Type | string |
| Required | No |
9. Property structuredAttrs
Title: Structured attributes
| Type | object |
| Required | No |
| Additional properties | Any type allowed |
Description: Structured Attributes, only defined if the derivation contains them. Structured attributes are JSON, and thus embedded as-is.