Managing External Dependencies with Chezmoi

Created:
Last Update:

Author: Christoph Stoettner
Read in about 3 min · 508 words

Pine leaves in winter

Photo by Toby Osborn | Unsplash

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.

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!

Comments
Error
There was an error sending your comment, please try again.
Thank you!
Your comment has been submitted and will be published once it has been approved.
Success!
Your comment has been posted successfully.

Comments

Loading comments...

Leave a Comment

Your email address will not be published. Required fields are marked with *

Suggested Reading
Card image cap

I attended Chemnitzer Linuxtage 2025 from Friday, March 21st to Sunday, March 23rd. It was my second time at the event, and I enjoyed it even more than last year. This time, approximately 3,500 people attended in person, with up to 250 parallel viewers joining the live streaming of lectures. You can find more details in the official blog post .

Created:
Last Update:
Read in about 3 min