Skip to content

.chezmoidata/

If any .chezmoidata/ directories exist in the source state, all files within them are interpreted as structured static data in the given formats. This data can then be used in templates. See also .chezmoidata.$FORMAT.

Info

Chezmoi supports multiple file $FORMATs for configuration and data: JSON, JSONC, TOML, and YAML.

Info

The files in the .chezmoidata directories all merge to the root of the data dictionary and are read in lexical (alphabetic) filesystem order. This applies both within .chezmoidata directories and between .chezmoidata directories.

As an example, if I have a .chezmoidata directory in my dot_config source directory, the files within will be merged according to the sort order of the files:

dot_config/.chezmoidata/zed.json
{ "z": { "z": 3 } }
dot_config/.chezmoidata/alpha.jsonc
{ "z": { "z": 4 } }
dot_config/.chezmoidata/beta.toml
z.x = 1
dot_config/.chezmoidata/gamma.yaml
z:
  y: 2

The output of chezmoi data will include the following merged z dictionary. Note that the value in .chezmoidata/zed.json overwrote the value in .chezmoidata/alpha.jsonc because of the lexical file sorting.

{
  "z": {
    "x": 1,
    "y": 2,
    "z": 3
  }
}

Warning

Files in .chezmoidata directories cannot be templates because they must be present prior to the start of the template engine. Dynamic machine data should be set in the data section of .chezmoi.$FORMAT.tmpl. Dynamic environment data should be read from templates using the output, fromJson, fromJson, or similar functions.