Chezmoi template helpers#

This page documents helper templates used across multiple rendered files.

expand-executable-paths.tmpl#

  • Input: full template context (.).

  • Behavior: reads .executable_paths for .chezmoi.os, prepends .chezmoi.homeDir for home_relative entries, appends absolute entries, returns JSON.

  • Output: JSON array intended for fromJson at call sites.

expand-executable-paths.tmpl#
 1{{- /* vim: set ft=gotmpl: */ -}}
 2{{- $cfg := index .executable_paths .chezmoi.os -}}
 3{{- $home := .chezmoi.homeDir -}}
 4{{- $paths := list -}}
 5{{- range $p := $cfg.home_relative -}}
 6  {{- $paths = append $paths (joinPath $home $p) -}}
 7{{- end -}}
 8{{- range $p := $cfg.absolute -}}
 9  {{- $paths = append $paths $p -}}
10{{- end -}}
11{{- $paths | toJson -}}

dotfiles-profile.tmpl#

  • Input: VVN_DOTFILES_PROFILE environment variable.

  • Behavior: normalizes to lowercase, allows minimal or standard, falls back to standard.

  • Output: selected profile name as plain text.

dotfiles-profile.tmpl#
1{{- /* vim: set ft=gotmpl: */ -}}
2{{- $profile := lower (env "VVN_DOTFILES_PROFILE") -}}
3{{- if or (eq $profile "minimal") (eq $profile "standard") -}}
4{{ $profile }}
5{{- else -}}
6standard
7{{- end -}}