I use chezmoi
for my dotfiles. To find out why and how to get started, check out my talk
from Chemnitzer Linuxtage 2025
.
Within chezmoi
, you can use the file .chezmoiexternal.toml
to download archives or git repositories during updates. This is particularly useful for managing external dependencies. Let me walk you through some common use cases.
Git Repositories
As I use Oh My Zsh
for my shell, I clone the repository to .oh-my-zsh
. That’s easy with this entry:
[".oh-my-zsh"]
type = "git-repo"
url = "https://github.com/ohmyzsh/ohmyzsh.git"
refreshPeriod = "168h"
This clones the repository to ~/.oh-my-zsh
(the path specified in the square brackets). To prevent Oh My Zsh’s built-in auto-update mechanism, I added the following line to my ~/.zshrc
:
DISABLE_AUTO_UPDATE="true"
This way, I let chezmoi
handle the updates instead of Oh My Zsh’s own update system.
Downloading Releases
When you want to get the latest release from a GitHub repository, you can configure it in .chezmoiexternal.toml
:
[".local/share"]
type = "archive"
url = "https://github.com/neovim/neovim/releases/latest/download/nvim-{{ .chezmoi.os }}-x86_64.tar.gz"
refreshPeriod = "168h"
This downloads the latest release of neovim
from GitHub and extracts the files to ~/.local/share
. The package extraction creates a folder named nvim-linux-x86_64
. I then created a symbolic link to a folder in my $PATH
:
ls ~/.local/bin/nvim -al
lrwxrwxrwx. 1 stoeps stoeps 56 Mar 5 20:41 /var/home/stoeps/.local/bin/nvim -> /var/home/stoeps/.local/share/nvim-linux-x86_64/bin/nvim
This symbolic link is also part of my Chezmoi repository.
With this setup, each time I run chezmoi apply
(but only once every 168 hours, which equals 7 days), I get the latest release of neovim
.
I manage this with chezmoi rather than within my distrobox/toolboxes because I want to use the latest and greatest neovim version across all my toolboxes.
Releases with Version Numbers (updated 2025-04-14)
Some GitHub software includes the version number in the filename, which means you can’t simply use “latest” in the URL.
In the initial version of the post, I showed a script to check for the version number and update .chezmoiexternal.toml
, but I got a mail from Tom Payne
the maintainer of chezmoi, who pointed me to the GitHub functions included
in chezmoi. He also sent me the link to his dotfiles repository with working examples
.
So we can just use gitHubLatestReleaseAssetURL
to get the latest version from Hugo:
[".local/bin/hugo"]
type = "archive-file"
url = {{ gitHubLatestReleaseAssetURL "gohugoio/hugo" (printf "hugo_*_%s-%s.tar.gz" .chezmoi.os .chezmoi.arch) | quote }}
executable = true
path = "hugo"
This extracts just the Hugo binary from the downloaded package and places it directly into ~/.local/bin/hugo
. The download URL uses variables for .chezmoi.os
and .chezmoi.arch
, which get replaced with the values from the running system (in my case, linux
and amd64
).
Since I build my blog with a GitLab action using the latest available Hugo version, it’s important for me to have an up-to-date version locally so I can test changes and new posts directly.
I really appreciate that Tom monitors articles and talks about chezmoi, and he also sent me a mail with a shortcut for my talk at Chemnitzer Linuxtage on the day of the talk. Thanks for the awesome tool Tom!