> ## Content Index
> Fetch the complete content index at: https://blog.wellslabs.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# Chezmoi
- URL: https://blog.wellslabs.org/chezmoi/
- Published: 2026-10-06T11:19:55.000Z
- Updated: 2026-10-06T23:24:15.000Z
- Author: James Wells

Chezmoi is a command-line utility designed to help you manage all of your config files from machine to machine or in my case, I am using it as a way to store my config files for a backup.

I wanted to have a way to back up all of my .config files now that I have been spending a good amount of time customizing my Omarchy desktop and CachyOS laptop. I spent a good amount of time with my laptop reading through the config for Hyprland, Noctalia, Neovim, Fish, and Alacritty. I took a deep dive into each of the documentations and looked for ways to customize them to my liking. I was thinking since DHH made Omarchy to be his operating system, I wanted to see how much efficiency I could gain and also add a little bit of my own style. 

I used OpenAI Codex to style the couple of changes that I made to Omarchy except for binding the extra buttons on my Logitech MX Master mouse. I had to do that on my own since I needed to figure out what the computer was seeing using wev. 

For my CachyOS laptop though, I made all of the configuration changes by hand. There was a couple of times that I used the web version of Claude to help me with Fish syntax, but I wanted to be the one to change my .config files because I didn't want to end up with more code or files than I actually needed. I am confident that Codex or Claude could have got me where I was going but they would have taken a couple of detours along the way and left some artifacts from them.

This is all to say that afterwards I wanted to sync my config to a Git repository. One of the first options I saw when I googled .config files and git was Chezmoi. I had never heard of it before, but I had all of the features that I was looking for and more. It's ability to encrypt files with age meant that I could feel comfortable syncing my ssh keys and config as well. 

The setup that I settled on was adding my SSH keys, SSH config file, and my age private key encrypted to the Chezmoi repository. I used a long passphrase for my age private key. I then created a script that asks for the passphrase when i connect a fresh install of Chezmoi to it and decrypts everything onto my computer. I even added a couple of scripts that install packages from Pacman and AUR once when a computer is first being setup. 

With this setup, I could wipe my laptop today, and I could very easily get back to a working setup. The only requirement is an SSH key with Chezmoi repository access or to use HTTPS the first time I access it.

Chezmoi also works on Windows, though the only thing I have been using Windows for is to play video games. I might look into setting it up and seeing if I can auto install programs on Windows as well.

The Chezmoi documentation can be found [here](https://www.chezmoi.io/) and their GitHub repository can be found [here](https://github.com/twpayne/chezmoi).

---

## Walkthrough

If anyone wants to tryout my Linux setup, I have detailed the steps below.

Install Chezmoi and Age(for encryption).

```bash
sudo pacman -S chezmoi age

```

Create Git Repository for Chezmoi config. (Forgejo Web UI)  
Initialize Chezmoi and Create Age Encryption Key.

```bash
chezmoi init
chezmoi cd

```

```chezmoi_shell
chezmoi age-keygen | chezmoi age encrypt --passphrase --output key.txt.age

```

Enter a passphrase for the private key.  
Create Chezmoi Ignore File.

```chezmoi_shell
printf '%s\n' \
'key.txt.age' \
'.ssh/known_hosts' \
'.ssh/known_hosts.old' \
>> .chezmoiignore

```

Create Scripts to run with Chezmoi.  
This one asks for the passphrase and then syncs the private key.  
run\_onchange\_before\_decrypt-private-key.sh.tmpl

```chezmoi_shell
#!/bin/sh

set -eu

KEY="${HOME}/.config/chezmoi/key.txt"

if [ ! -f "${KEY}" ]; then
    mkdir -p "${HOME}/.config/chezmoi"

    chezmoi age decrypt \
        --output "${KEY}" \
        --passphrase \
        "{{ .chezmoi.sourceDir }}/key.txt.age"

    chmod 600 "${KEY}"
fi

```

Create Scripts to add packages to new computer.  
run\_once\_before\_10-install-packages.sh.tmpl

```chezmoi_shell
#!/bin/bash
set -e

SOURCE="{{ .chezmoi.sourceDir }}"

if [[ -f "$SOURCE/packages-pacman.txt" ]]; then
    sudo pacman -S --needed --noconfirm \
        $(grep -vE '^\s*(#|$)' "$SOURCE/packages-pacman.txt")
fi

if command -v paru >/dev/null 2>&1 && [[ -f "$SOURCE/packages-aur.txt" ]]; then
    paru -S --needed --noconfirm \
        $(grep -vE '^\s*(#|$)' "$SOURCE/packages-aur.txt")
fi

```

Create Package Manifest Files

```chezmoi_shell
printf '%s\n' \
chromium \
ttf-jetbrains-mono-nerd \
tailscale \
fzf \
zoxide \
eza \
fd \
bat \
tmux \
openai-codex \
obsidian \
dua-cli \
yay \
nautilus \
neovim \
git \
ripgrep \
lazygit \
> packages-pacman.txt

```

```chezmoi_shell
printf '%s\n' \
facelock-bin \
> packages-aur.txt

```

Retrieve Age Public Key and Create Chezmoi Config File.

```chezmoi_shell
chezmoi age decrypt --passphrase ./key.txt.age

```

Copy the Public Key right now so that you can put it in the Chezmoi config file. This .tmpl file will be used to create the chezmoi config file on machines.

Create \~/.config/chezmoi/chezmoi.toml.tmpl

```toml
encryption = "age"

[age]
    identity = "~/.config/chezmoi/key.txt"
    recipient = "age1ks93xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

```

```bash
chezmoi init --apply

```

Add files to Chezmoi. I would not add the entire .config directory because there are a lot of programs that use it for temporary storage as well.

```bash
chezmoi add -r ~/.config/{hypr,noctalia,alacritty,fish,nvim}

```

```bash
chezmoi add --encrypt -r ~/.ssh

```

Push first commit to repository.

```shell
git config --global user.name "$UserName"
git config --global user.email "$EmailAddress"

```

```bash
chezmoi cd;

```

```chezmoi_shell
git add .
git commit -m "First Commit"
git branch -M main
git remote add origin $RepositoryURL
git push -u origin main

```

```chezmoi_shell
exit

```

Apply Chezmoi Configuration

```bash
chezmoi apply -v

```

To push changes to Chezmoi Repository

```shell
chezmoi push

```

Add new files

```shell
chezmoi add $filePath

```

Apply local changes made to files.

```shell
chezmoi re-add
chezmoi push

```

## After Initial Setup

After the initial setup, when you want to clone you repo to another machine, you only need to install chezmoi and age. Then run these commands.

```bash
chezmoi init --apply $repository
```