Setup
The chosen configuration controls the behavior during these sequential steps:
- Repository cloning
chezmoiinitializationchezmoiapplication of dotfiles from the source directory on the target directory.
Environment Variables
Environment variables that determine the templating environment:
| envvar | description | allowed values | default value | on invalid value |
|---|---|---|---|---|
DOTFILES_VERBOSE | Enable verbose output for operations | "true", "false" | "false" | Use default |
DOTFILES_PROFILE | Profile name | "personal", "quantica" | "personal" | Use default |
DOTFILES_APPLY | Controls if the --apply flag is passed during initialization | "true", "false" | "true" | WARNING; Use default |
DOTFILES_GIT_BRANCH | Git branch or ref to checkout | Any valid git ref | "HEAD" | WARNING; Disable chezmoi apply |
DOTFILES_DEVBOX_ENABLED | Enable or disable Devbox and Direnv | "true", "false" | "true" | ERROR |
They are used once during chezmoi initialization to set template data dynamically in .chezmoi.yaml.tmpl, which results in the final ~/.config/chezmoi/chezmoi.yaml that is installed, which contains static template data. Example:
DOTFILES_PROFILE=personal chezmoi initor
export DOTFILES_PROFILE=personal
chezmoi initor simply using envrar auto-loading (direnv) as
chezmoi initIf .chezmoi.yaml.tmpl is modified, ~/.config/chezmoi/chezmoi.yaml can be re-generated by re-initializing chezmoi as chezmoi init (using the current source repo), providing the necessary envvars.
DevPod
Environment variables can be made available to devpod installation of dotfiles by option --dotfiles-script-env ENVVAR=VALUE,... or --dotfiles-script-env-file env_file.... Example using default profile:
devpod up . --dotfiles-script-env DOTFILES_PROFILE=personalor
devpod up . --dotfiles-script-env-file path/to/env/fileAuto-Loading Environment Variables
With Mise
It is the preferred way, as it is more efficient, clean, and does not rely on external dependencies like Devbox does on Direnv. Mise centralizes the management of packages, environment variables and tasks. Mise environments activation, both global and per-project, is managed through a Bash init hook.
With Direnv (deprecated)
Shell hooks are set for direnv to auto-load and unload envvars found in the first found .envrc file up the PWD path.
Particularly, ~/.envrc is tracked and includes templating config envvars. This allows to re-initialize as chezmoi init from home directory without the need to pass or export templating envvars explicitly, as they are auto-loaded and exported.
During chezmoi`` initialization, and especially during non-interactive installation bydevpod,~/.envrcwill be allowed implicitly bydirenv, since it is in thedirenv` whitelist.
~/.dotfiles.env file is to contain envars used to configure the chezmoi dynamic template initialization. As a conventional dotenv file (KEY=VALUE pairs), it can be passed to devpod as
devpod up path/to/repo/ --dotfiles-script-env-file=~/.dotfiles.envAdditionally it is made available by direnv in the home environment (~/.envrc) so that chezmoi init uses its current config without having to pass envvars explicitly.
Installation Script
The cloned dotfiles Git repository will be configured with the personal profile email address, even in an environment with another profile.