Home Explore Blog CI



nix

5th chunk of `doc/manual/source/language/advanced-attributes.md`
3954c9f7b4d5ed06ef074011c3a07f13f0065bcb7460180500000001000009bc
  `__contentAddressed` is ignored, because fixed-output derivations always content-address their outputs, by definition.

  **TODO CHECK**

  -->

- [(Floating) content-addressing derivations](@docroot@/store/derivation/outputs/content-address.md)

  Both [`outputHashAlgo`] and [`outputHashMode`], `__contentAddressed = true;`, and *not* `outputHash`.

  If an output hash was given, then the derivation output would be "fixed" not "floating".

Here is more information on the `output*` attributes, and what values they may be set to:

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

    This specifies how the files of a content-addressing derivation output are digested to produce a content address.

    This works in conjunction with [`outputHashAlgo`](#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 `outputHashMode` attribute determines how the hash is computed.
    It must be one of the following values:

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

        This is the default.

      - [`"recursive"` or `"nar"`](@docroot@/store/store-object/content-address.md#method-nix-archive)

        > **Compatibility**
        >
        > `"recursive"` is the traditional way of indicating this,
        > and is supported since 2005 (virtually the entire history of Nix).
        > `"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).

Title: Content-Addressing Derivations and Output Hash Modes & Algorithms
Summary
This section describes content-addressing derivations, specifying they require both `outputHashAlgo` and `outputHashMode`, with `__contentAddressed = true` and the absence of `outputHash`. It details the `outputHashMode` attribute, which determines how files are digested to produce a content address, listing the possible values: `flat` (default), `recursive`/`nar`, `text` (experimental), and `git` (experimental). It also explains `outputHashAlgo`, specifying the hash algorithm used for content-addressing derivation outputs, requiring its use with `outputHashMode`.