Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Resolved Derivation

Title: Resolved Derivation

Typeobject
RequiredNo
Additional propertiesNot allowed

Description: Experimental JSON representation of a resolved Nix derivation (version 4).

This schema describes the JSON representation of Nix’s BasicDerivation type, which is a derivation with all input derivation dependencies resolved to store paths. This is the result of Derivation::tryResolve.

This is called “version 4” because we wish to keep it in sync with the primary (not necessarily resolved) JSON schema, but actually it is the first version for this format.

Warning

This JSON format is currently experimental and subject to change.

PropertyTypePatternTitle/Description
+ namestringNoDerivation name
+ versionconstNoFormat version (must be 4)
+ outputsobjectNoOutput specifications
+ systemstringNoBuild system type
+ builderstringNoBuild program path
+ argsarray of stringNoBuilder arguments
+ envobjectNoEnvironment variables
- structuredAttrsobjectNoStructured attributes
+ inputsarrayNoInput source paths

1. Property name

Title: Derivation name

Typestring
RequiredYes
Defined inderivation-v4.yamlJSON format for Derivation

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)

Typeconst
RequiredYes
Defined inderivation-v4.yamlJSON format for Derivation

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 method and hashAlgo fields 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.srcs and inputs.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

Typeobject
RequiredYes
Additional propertiesEach additional property must conform to the schema
Defined inderivation-v4.yamlJSON format for Derivation

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"
  }
}
PropertyTypePatternTitle/Description
- objectNoDerivation Output

3.1. Property Derivation Output

Title: Derivation Output

Typecombining
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/output/overall

Description: A single output of a derivation, with different variants for different output types.

3.1.1. Property Input-Addressed Output

Title: Input-Addressed Output

Typeobject
RequiredNo
Additional propertiesNot 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.

PropertyTypePatternTitle/Description
+ pathstringNoOutput path
3.1.1.1. Property path

Title: Output path

Typestring
RequiredYes
Defined instore-path-v1.yaml

Description: The output path determined from the derivation itself.

Restrictions
Min length34
Must match regular expression^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+$ Test

3.1.2. Property Fixed Content-Addressed Output

Title: Fixed Content-Addressed Output

Typeobject
RequiredNo
Additional propertiesNot 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.

PropertyTypePatternTitle/Description
+ methodenum (of string)NoContent-Addressing Method
+ hashstringNoExpected hash value
3.1.2.1. Property method

Title: Content-Addressing Method

Typeenum (of string)
RequiredYes
Defined inJSON 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

Typestring
RequiredYes
Defined inJSON 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

Typeobject
RequiredNo
Additional propertiesNot 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.

PropertyTypePatternTitle/Description
+ methodenum (of string)NoContent-Addressing Method
+ hashAlgoenum (of string)NoHash algorithm
3.1.3.1. Property method

Title: Content-Addressing Method

Typeenum (of string)
RequiredYes
Same definition asmethod

Description: Method of content addressing used for this output.

3.1.3.2. Property hashAlgo

Title: Hash algorithm

Typeenum (of string)
RequiredYes
Defined inJSON 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

Typeobject
RequiredNo
Additional propertiesAny 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

Typeobject
RequiredNo
Additional propertiesNot 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.

PropertyTypePatternTitle/Description
+ impureconstNo-
+ methodenum (of string)NoContent-Addressing Method
+ hashAlgoenum (of string)NoHash algorithm
3.1.5.1. Property impure
Typeconst
RequiredYes

Specific value: true

3.1.5.2. Property method

Title: Content-Addressing Method

Typeenum (of string)
RequiredYes
Same definition asmethod

Description: How the file system objects will be serialized for hashing.

3.1.5.3. Property hashAlgo

Title: Hash algorithm

Typeenum (of string)
RequiredYes
Defined inJSON format for Hash

Description: How the serialization will be hashed.

Must be one of:

  • “blake3”
  • “md5”
  • “sha1”
  • “sha256”
  • “sha512”

4. Property system

Title: Build system type

Typestring
RequiredYes
Defined inderivation-v4.yamlJSON format for Derivation

Description: The system type on which this derivation is to be built (e.g. x86_64-linux).

5. Property builder

Title: Build program path

Typestring
RequiredYes
Defined inderivation-v4.yamlJSON format for Derivation

Description: Absolute path of the program used to perform the build. Typically this is the bash shell (e.g. /nix/store/p4xlj4imjbnm4v0x5jf4qysvyjjlgq1d-bash-4.4-p23/bin/bash).

6. Property args

Title: Builder arguments

Typearray of string
RequiredYes
Defined inderivation-v4.yamlJSON format for Derivation

Description: Command-line arguments passed to the builder.

Array restrictions
Min itemsN/A
Max itemsN/A
Items unicityFalse
Additional itemsFalse
Tuple validationSee below
Each item of this array must beDescription
args items-

6.1. args items

Typestring
RequiredNo

7. Property env

Title: Environment variables

Typeobject
RequiredYes
Additional propertiesEach additional property must conform to the schema
Defined inderivation-v4.yamlJSON format for Derivation

Description: Environment variables passed to the builder.

PropertyTypePatternTitle/Description
- stringNo-

7.1. Property additionalProperties

Typestring
RequiredNo

8. Property structuredAttrs

Title: Structured attributes

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined inderivation-v4.yamlJSON format for Derivation

Description: Structured Attributes, only defined if the derivation contains them. Structured attributes are JSON, and thus embedded as-is.

PropertyTypePatternTitle/Description
- objectNo-

9. Property inputs

Title: Input source paths

Typearray
RequiredYes

Description: List of store paths on which this resolved derivation depends. Since all derivation inputs have been resolved, only source paths remain.

Example

"inputs": [
  "b8nwz167km1yciqpwzjj24f8jcy8pq1h-separate-debug-info.sh",
  "f1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-dep1-out"
]
Array restrictions
Min itemsN/A
Max itemsN/A
Items unicityFalse
Additional itemsFalse
Tuple validationSee below
Each item of this array must beDescription
Store PathA store path identifying a store object. …

9.1. Store Path

Title: Store Path

Typestring
RequiredNo
Same definition aspath

Description: A store path identifying a store object.

This schema describes the JSON representation of store paths as used in various Nix JSON APIs.

Warning

This JSON format is currently experimental and subject to change.

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 Nix32 (20 hash bytes become 32 ASCII characters)
  • name: The package name and optional version/suffix information