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

Provenance

Title: Provenance

Typecombining
RequiredNo
Additional propertiesAny type allowed

Description: > Warning

This JSON format is currently experimental and subject to change.

Provenance describes where a store object came from, such as the derivation that built it, the flake output that produced that derivation, or the source tree that it was fetched from. It appears in the provenance field of store object info, as shown by e.g. nix path-info --json.

A provenance record is a JSON object with a type field that determines what other fields are present. Most types have a next field that contains the provenance of the thing from which this one was derived (or null if that isn’t known). Thus, provenance forms a chain, going from the store object itself back to its ultimate origin. For example, a store object substituted from a binary cache might have copied provenance, whose next is build provenance, whose next is derivation provenance, and so on.

Future versions of Nix may add new provenance types, and new fields to existing types. Consumers should therefore accept provenance records with a type that they don’t recognise, and ignore fields that they don’t recognise. Nix itself preserves records of unknown types unchanged.

1. Property Build

Title: Build

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/build

Description: The store object is an output of a derivation that was built locally or on a remote builder.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ drvstringNoDerivation
+ outputstringNoOutput Name
- buildHostCombinationNoBuild Host
+ systemstringNoSystem
- tagsobjectNoTags
- nextobjectNoNext

1.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “build”

1.2. Property drv

Title: Derivation

Typestring
RequiredYes
Defined inJSON format for StorePath

Description: The store derivation that was built.

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

1.3. Property output

Title: Output Name

Typestring
RequiredYes

Description: The name of the derivation output that corresponds to this store object, e.g. out.

1.4. Property buildHost

Title: Build Host

Typecombining
RequiredNo
Additional propertiesAny type allowed

Description: The hostname of the machine on which the derivation was built, or null if not known.

One of(Option)
item 0
item 1

1.4.1. Property item 0

Typestring
RequiredNo

1.4.2. Property item 1

Typenull
RequiredNo

1.5. Property system

Title: System

Typestring
RequiredYes

Description: The system type of the derivation, e.g. x86_64-linux.

1.6. Property tags

Title: Tags

Typeobject
RequiredNo
Additional propertiesNot allowed

Description: User-defined key/value pairs from the build-provenance-tags setting on the build host, e.g. a CI job URL.

PropertyTypePatternTitle/Description
- ^[A-Za-z_][A-Za-z0-9_+-]*$stringYes-

1.6.1. Pattern Property ^[A-Za-z_][A-Za-z0-9_+\-]*$

All properties whose name matches the regular expression ^[A-Za-z_][A-Za-z0-9_+\-]*$ (Test) must respect the following conditions

Typestring
RequiredNo

1.7. Property next

Title: Next

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

Description: The provenance of the derivation, typically of type derivation.

One of(Option)
item 0
Provenance

1.7.1. Property item 0

Typenull
RequiredNo

1.7.2. Property Provenance

Title: Provenance

Typecombining
RequiredNo
Additional propertiesAny type allowed
Same definition asProvenance

Description: > Warning

This JSON format is currently experimental and subject to change.

Provenance describes where a store object came from, such as the derivation that built it, the flake output that produced that derivation, or the source tree that it was fetched from. It appears in the provenance field of store object info, as shown by e.g. nix path-info --json.

A provenance record is a JSON object with a type field that determines what other fields are present. Most types have a next field that contains the provenance of the thing from which this one was derived (or null if that isn’t known). Thus, provenance forms a chain, going from the store object itself back to its ultimate origin. For example, a store object substituted from a binary cache might have copied provenance, whose next is build provenance, whose next is derivation provenance, and so on.

Future versions of Nix may add new provenance types, and new fields to existing types. Consumers should therefore accept provenance records with a type that they don’t recognise, and ignore fields that they don’t recognise. Nix itself preserves records of unknown types unchanged.

2. Property Copied

Title: Copied

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/copied

Description: The store object was copied from another store, typically substituted from a binary cache.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ fromstringNoFrom
- nextobjectNoNext

2.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “copied”

2.2. Property from

Title: From

Typestring
RequiredYes

Description: The URL of the store from which the store object was copied.

2.3. Property next

Title: Next

Typecombining
RequiredNo
Additional propertiesAny type allowed
Same definition asnext

Description: The provenance of the store object in the store from which it was copied.

3. Property Derivation

Title: Derivation

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/derivation

Description: The store object is a store derivation that was instantiated by builtins.derivationWithMeta.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ metaobjectNoMetadata
- nextobjectNoNext

3.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “derivation”

3.2. Property meta

Title: Metadata

Typeobject
RequiredYes
Additional propertiesAny type allowed

Description: The value of the __meta attribute passed to derivationWithMeta, converted to JSON.

3.3. Property next

Title: Next

Typecombining
RequiredNo
Additional propertiesAny type allowed
Same definition asnext

Description: The provenance of the Nix expression that instantiated the derivation, typically of type flake.

4. Property Flake

Title: Flake

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/flake

Description: The thing was produced by evaluating a flake output.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ flakeOutputstringNoFlake Output
- purebooleanNoPure
- nextobjectNoNext

4.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “flake”

4.2. Property flakeOutput

Title: Flake Output

Typestring
RequiredYes

Description: The attribute path of the flake output that was evaluated, e.g. packages.x86_64-linux.default.

4.3. Property pure

Title: Pure

Typeboolean
RequiredNo

Description: Whether the flake output was evaluated in pure evaluation mode. Defaults to true if absent.

4.4. Property next

Title: Next

Typecombining
RequiredNo
Additional propertiesAny type allowed
Same definition asnext

Description: The provenance of the flake’s flake.nix file, typically of type subpath.

5. Property Subpath

Title: Subpath

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/subpath

Description: The thing is a file or directory inside another source tree.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ subpathstringNoSubpath
- nextobjectNoNext

5.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “subpath”

5.2. Property subpath

Title: Subpath

Typestring
RequiredYes

Description: The absolute path of the file or directory within the source tree, e.g. /flake.nix.

5.3. Property next

Title: Next

Typecombining
RequiredNo
Additional propertiesAny type allowed
Same definition asnext

Description: The provenance of the source tree, typically of type tree.

6. Property Tree

Title: Tree

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/tree

Description: The thing is a source tree fetched by a fetcher, e.g. a flake input.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ attrsobjectNoAttributes

6.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “tree”

6.2. Property attrs

Title: Attributes

Typeobject
RequiredYes
Additional propertiesEach additional property must conform to the schema

Description: The attributes of the locked input, as accepted by builtins.fetchTree, except narHash.

PropertyTypePatternTitle/Description
- string, integer or booleanNo-

6.2.1. Property additionalProperties

Typestring, integer or boolean
RequiredNo

7. Property Fetchurl

Title: Fetchurl

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/fetchurl

Description: The store object was downloaded from a URL, e.g. by builtins.fetchurl.

PropertyTypePatternTitle/Description
+ typeenum (of string)No-
+ urlstringNoURL

7.1. Property type

Typeenum (of string)
RequiredYes

Must be one of:

  • “fetchurl”

7.2. Property url

Title: URL

Typestring
RequiredYes

Description: The URL from which the store object was downloaded, with any credentials removed.

8. Property Unknown

Title: Unknown

Typeobject
RequiredNo
Additional propertiesAny type allowed
Defined in#/$defs/unknown

Description: A provenance type not known to this version of Nix.

PropertyTypePatternTitle/Description
+ typeCombinationNo-

8.1. Property type

Typecombining
RequiredYes

8.1.1. Must not be

Typeenum (of string)
RequiredNo

Must be one of:

  • “build”
  • “copied”
  • “derivation”
  • “flake”
  • “subpath”
  • “tree”
  • “fetchurl”

Examples

Build provenance

A store object built from a flake output, showing the full provenance chain back to the flake’s source tree:

{
    "buildHost": "builder-1",
    "drv": "lhj2ix9nrbw9wjab4ywsg9xvc86fm8in-hello-2.12.2.drv",
    "next": {
        "meta": {
            "description": "Program that produces a familiar, friendly greeting",
            "license": {
                "free": true,
                "spdxId": "GPL-3.0-or-later"
            }
        },
        "next": {
            "flakeOutput": "packages.x86_64-linux.default",
            "next": {
                "next": {
                    "attrs": {
                        "lastModified": 1760000000,
                        "owner": "NixOS",
                        "repo": "nixpkgs",
                        "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
                        "type": "github"
                    },
                    "type": "tree"
                },
                "subpath": "/flake.nix",
                "type": "subpath"
            },
            "pure": true,
            "type": "flake"
        },
        "type": "derivation"
    },
    "output": "out",
    "system": "x86_64-linux",
    "tags": {
        "ci-job": "https://ci.example.org/jobs/1234"
    },
    "type": "build"
}

Copied provenance

A store object substituted from a binary cache:

{
    "from": "https://cache.example.org",
    "next": {
        "buildHost": null,
        "drv": "lhj2ix9nrbw9wjab4ywsg9xvc86fm8in-hello-2.12.2.drv",
        "next": null,
        "output": "out",
        "system": "x86_64-linux",
        "tags": {},
        "type": "build"
    },
    "type": "copied"
}

Source file

A file inside a Git repository:

{
    "next": {
        "attrs": {
            "lastModified": 1760000000,
            "ref": "refs/heads/main",
            "rev": "8f2b1c0d9e4a7b6c5d3e2f1a0b9c8d7e6f5a4b3c",
            "revCount": 42,
            "type": "git",
            "url": "https://example.org/repo.git"
        },
        "type": "tree"
    },
    "subpath": "/builder.sh",
    "type": "subpath"
}

Fetched URL

{
    "type": "fetchurl",
    "url": "https://ftp.gnu.org/gnu/hello/hello-2.12.2.tar.gz"
}