Home Explore Blog CI



nix

6th chunk of `doc/manual/source/language/advanced-attributes.md`
35e4d6e312fe5389db7d2f46e373373c7aa7882ec64265430000000100000d91
        > `"nar"` is more clear, and consistent with other parts of Nix (such as the CLI),
        > however support for it is only added in Nix version 2.21.

      - [`"text"`](@docroot@/store/store-object/content-address.md#method-text)

        > **Warning**
        >
        > The use of this method for derivation outputs is part of the [`dynamic-derivations`][xp-feature-dynamic-derivations] experimental feature.

      - [`"git"`](@docroot@/store/store-object/content-address.md#method-git)

        > **Warning**
        >
        > This method is part of the [`git-hashing`][xp-feature-git-hashing] experimental feature.

    See [content-addressing store objects](@docroot@/store/store-object/content-address.md) for more information about the process this flag controls.

  - [`outputHashAlgo`]{#adv-attr-outputHashAlgo}

    This specifies the hash algorithm used to digest the [file system object] data of a content-addressing derivation output.

    This works in conjunction with [`outputHashMode`](#adv-attr-outputHashAlgo).
    Specifying one without the other is an error (unless `outputHash` is also specified and includes its own hash algorithm as described below).

    The `outputHashAlgo` attribute specifies the hash algorithm used to compute the hash.
    It can currently be `"blake3"`, `"sha1"`, `"sha256"`, `"sha512"`, or `null`.

    `outputHashAlgo` can only be `null` when `outputHash` follows the SRI format, because in that case the choice of hash algorithm is determined by `outputHash`.

  - [`outputHash`]{#adv-attr-outputHashAlgo}; [`outputHash`]{#adv-attr-outputHashMode}

    This will specify the output hash of the single output of a [fixed-output derivation].

    The `outputHash` attribute must be a string containing the hash in either hexadecimal or "nix32" encoding, or following the format for integrity metadata as defined by [SRI](https://www.w3.org/TR/SRI/).
    The "nix32" encoding is an adaptation of base-32 encoding.

    > **Note**
    >
    > The [`convertHash`](@docroot@/language/builtins.md#builtins-convertHash) function shows how to convert between different encodings.
    > The [`nix-hash` command](../command-ref/nix-hash.md) has information about obtaining the hash for some contents, as well as converting to and from encodings.

  - [`__contentAddressed`]{#adv-attr-__contentAddressed}

    > **Warning**
    >
    > This attribute is part of an [experimental feature](@docroot@/development/experimental-features.md).
    >
    > To use this attribute, you must enable the
    > [`ca-derivations`][xp-feature-ca-derivations] experimental feature.
    > For example, in [nix.conf](../command-ref/conf-file.md) you could add:
    >
    > ```
    > extra-experimental-features = ca-derivations
    > ```

    This is a boolean with a default of `false`.
    It determines whether the derivation is floating content-addressing.

[`__contentAddressed`]: #adv-attr-__contentAddressed
[`outputHash`]: #adv-attr-outputHash
[`outputHashAlgo`]: #adv-attr-outputHashAlgo
[`outputHashMode`]: #adv-attr-outputHashMode

[fixed-output derivation]: @docroot@/glossary.md#gloss-fixed-output-derivation
[file system object]: @docroot@/store/file-system-object.md
[store object]: @docroot@/store/store-object.md
[xp-feature-dynamic-derivations]: @docroot@/development/experimental-features.md#xp-feature-dynamic-derivations
[xp-feature-git-hashing]: @docroot@/development/experimental-features.md#xp-feature-git-hashing

Title: Details on outputHashAlgo, outputHash, and __contentAddressed Attributes
Summary
This section elaborates on `outputHashAlgo`, specifying that it defines the hash algorithm for content-addressing derivation outputs and can be `blake3`, `sha1`, `sha256`, `sha512`, or `null` (when `outputHash` follows the SRI format). It also explains `outputHash`, which provides the output hash of a fixed-output derivation, accepting hexadecimal, "nix32", or SRI-formatted hashes. Lastly, it discusses `__contentAddressed`, an experimental boolean attribute that determines if a derivation is floating content-addressing, requiring the `ca-derivations` experimental feature to be enabled.