Skip to content

Setup

The chosen configuration controls the behavior during these sequential steps:

  • Repository cloning
  • chezmoi initialization
  • chezmoi application of dotfiles from the source directory on the target directory.

Environment Variables

Environment variables that determine the templating environment:

envvardescriptionallowed valuesdefault valueon invalid value
DOTFILES_PROFILEProfile name"personal", "quantica""personal"Use default
DOTFILES_APPLYControls if the --apply flag is passed during initialization"true", "false""true"WARNING; Use default
DOTFILES_GIT_BRANCHGit branch or ref to checkoutAny valid git ref"HEAD"WARNING; Disable chezmoi apply
DOTFILES_DEVBOX_ENABLEDEnable or disable Devbox bootstrapping"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:

sh
DOTFILES_PROFILE=personal chezmoi init

or

sh
export DOTFILES_PROFILE=personal
chezmoi init

or simply using envrar auto-loading (direnv) as

sh
chezmoi init

If .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:

sh
devpod up . --dotfiles-script-env DOTFILES_PROFILE=personal

or

sh
devpod up . --dotfiles-script-env-file path/to/env/file

Auto-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

sh
devpod up path/to/repo/ --dotfiles-script-env-file=~/.dotfiles.env

Additionally 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.