How to setup my local machine with Chezmoi and Mise

Published August 21, 2026

View last change

84e3a3c — added titles

Install Chezmoi manually

The following command will install Chezmoi on my machine, apply my dotfiles repo to configure all my dotfiles, install Mise, and use Mise to install any tools I’d like installed by default.

# run the following command to install chezmoi and apply my dotfiles.
sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply https://github.com/jackykornet/dotfiles.git

What is happening:

  • sh -c "$(curl -fsLS get.chezmoi.io)" downloads the binary and installs the latest version of Chezmoi.
  • -- passes parameters to the Chezmoi installation. If parameters are passed, Chezmoi starts after the installation with these parameters.
  • init initiates a new installation
  • --apply https://github.com/jackykornet/dotfiles.git applies an existing dotfiles repo to the home directory

Adding --apply is the same as running Chezmoi apply. The following is happening (in order of application):

  1. Checks the state of the source (this is the working directory $HOME/.local/chezmoi, and the place where the git repo is pulled)
  2. Checks the state of the destination. (this is the home directory where the actual dotfiles live)
  3. Computes the target state (the difference between the source and destination).
  4. Applies updates to the target. The order of application is based on alphabetic order. Target names are considered after all attributes are stripped.
    • First it will run all the scripts with the before attribute before_
    • Then it will process all the other files and scripts
    • At the end all the after_ scripts will run.

When not applying the —apply parameter Chezmoi will only copy the files to the working directory, so you can check the difference between the source and destination before running Chezmoi apply manually.

Script attributes

There are multiple script attributes available, running at different times in the process.

  • run_before_ — run before everything else.
  • run_once — run once if success and not changed.
  • run_onchange — run only on change. Can also be used for tracking changes of external files.

It is also possible to combine attributes together.

  • run_once_before_ — run once before anything else
  • run_onchange_after_ — run onchange after anything else

See https://www.chezmoi.io/reference/source-state-attributes/ for all possible attributes

Install Mise

With .chezmoiexternals external programs can be installed. To install Mise create a file in .chezmoiexternals with the .toml extension.

tree — file tree of the .chezmoiexternals directory

.
├── .chezmoiexternals
│   └── mise.toml

Add the configuration for the installation of the Mise binary.

content of the mise.toml file

[".local/bin/mise"]
type = "file"
executable = true
url = "https://mise.jdx.dev/mise-latest-{{.chezmoi.os}}-{{.chezmoi.arch}}"

What this file does:

  • [".local/bin/mise"] installs the program to this location
  • type = "file" as a file
  • executable = true makes the file executable
  • url = "https://mise.jdx.dev/mise-latest-{{.chezmoi.os}}-{{.chezmoi.arch}}" from this URL.
    • Templating variables are used to get the right installation package, based on the os and architecture of the machine.

All the possible template variables can be seen by running the command chezmoi data

Install tools with Mise

To manually install tools with Mise run the command $HOME/.local/bin/mise install. This will install all tools specified in .config/mise/config.toml.

To install tools automatically using Chezmoi use a run_onchange_after script. Create a file run_onchange_after_install_packages.sh.tmp in .chezmoiscripts.

├── .chezmoiscripts
│   └── run_onchange_after_install_packages.sh.tmpl

Add the following content to the file

run_onchange_after_install_packages.sh.tmp

#!/bin/bash
# packages hash: {{ include "dot_config/mise/config.toml" | sha256sum }}
$HOME/.local/bin/mise trust $HOME/.config/mise/config.toml && $HOME/.local/bin/mise install

To check if a file is changed Chezmoi is creating a hash of the file content. When the hash changes, the file is changed and it will run again. It is also possible to include external files into the hash by adding the following line.

What this file does:

  • # packages hash: {{ include "dot_config/mise/config.toml" | sha256sum }} includes dot_config/mise/config.toml in the hash calculation.
  • $HOME/.local/bin/mise trust $HOME/.config/mise/config.toml trusts the config file.
  • $HOME/.local/bin/mise install runs mise install to install the tools.

When dot_config/mise/config.toml changes, the hash will change and the run_onchange_after_install_packages.sh.tmp script will run again.

Why the order of trust matters

By default Mise doesn’t use any external configuration files unless instructed to do so. This is to prevent any harmful scripts from being executed from untrusted sources. If we do not first trust the config.toml file before running install, Mise will not process the config.toml.

Files and folders

This is a brief overview of the most valuable files and locations used by Chezmoi and Mise

WhatWhere
Chezmoi binary (by Mise)~/.local/share/mise/installs/chezmoi/latest/chezmoi
Chezmoi binary installed by hand{$PWD}\bin\chezmoi
Chezmoi source directory~/.local/share/chezmoi
Mise binary~/.local/bin/mise
Mise tools binary~/.local/share/mise/installs/
Mise config file~/.config/mise/config.toml
dot_file files~/.file
dot_config folder~/.config/
dot_config/anything~/.config/anything

Git repo structure

A brief explanation of the git repo structure and how Chezmoi processes them.

dotfile repo structure

dotfiles/
├── .chezmoiexternals      #-- external script location
│   └── mise.toml
├── .chezmoiignore         #-- files to ignore
├── .chezmoiscripts        #-- script to run during apply
│   └── run_onchange_after_install_packages.sh.tmpl
├── README.md
├── dot_bashrc             #-- will be copied to ~/.bashrc
├── dot_config             #-- everything inside will be copied to ~/.config. If .config doesn't exist it will be created.
│   ├── mise
│   │   └── config.toml    #-- will be copied to ~/.config/mise/config.toml
│   └── starship.toml
├── dot_vimrc              #-- will be copied to ~/.vimrc
└── setup                  #-- DevPod bootstrap (must be executable). Ignored by Chezmoi (see .chezmoiignore)

Useful Commands

An overview of the most useful commands you use while working with Chezmoi or Mise

## Chezmoi

# cd in to chezmoi source dir, same as cd ~/.local/share/chezmoi
chezmoi cd

# Apply dotfiles locally
chezmoi apply

# Dry run with verbose logging. Does not apply anything.
chezmoi apply --dry-run --verbose

# Shows the difference between the working dir and home directory
chezmoi diff

# Pull :latest from remote and runs apply
chezmoi update

# Add a managed file (copies the existing file to dot_bashrc)
chezmoi add ~/.bashrc

# Edit a managed file
chezmoi edit ~/.bashrc

# Remove run_once states, all scripts run again after apply
chezmoi state delete-bucket --bucket=scriptState
chezmoi apply

# The git commands to use after changing dotfiles.
# add to staging
git add .

# commit changes
git commit -m "message"

# push to repo
git push

##
## Mise
##

# List installed tools
mise list

# Shows trusted config files
mise trust

# Trust config file ~/.config/mise/config.toml
mise trust ~/.config/mise/config.toml

# Install tools from config.toml
mise install

# Add a tool (adds it also to config.toml)
mise use bat@latest

Questions or thoughts about this post? Reach me at jacky@tenrok.nl or on LinkedIn.