35 points · by mthwsjc_ · 5y ago · 19 comments
What tools would you recommend for managing dotfiles that are robust, doesn't have external dependencies, uses git and are idempotent?
I'd like something that manages directories of files (e.g. ~/.vim/ftplugin/) in sub-directories, as well as in $HOME. If the tool can deal with multiple systems (MacOS, CentOS, debian) then even better!
Thanks!
I made a dotfile management tool: https://github.com/knoebber/dotfile , but it's not based on git or designed for directories of files.
I think Chezmoi would fit your usecase well: https://www.chezmoi.io/
As a disclaimer I have to say I have never migrated my system to another one or even shared my config, so unforeseen problems may appear.
*
!/.bashrc
!/.config/
!/.config/monitors.xml
This lets me quickly quickly detect changes in my working dir while still explicitly adding each tracked file.I specifically have a design goal of very little external dependency. It only requires Git and Bash be present, so it is quite portable. Many people even use it on some network equipment. You can simply download the script if it isn’t packaged somewhere.
It can easily handle directories of files, but also submodules. Many people add vim plugin Git repos directly as submodules.
If you are familiar with Git, you’ll find yadm extremely easy to use. When you need them, more features are there to solve specific problems, like bootstrapping operations, encrypting private data, templating, or system dependent alternate files.
On a new system you can quickly bootstrap your existing dotfiles repo using https://bootstrap.yadm.io, without yadm installed yet. This is mostly useful if you’ve included yadm directly in you dotfiles (directly, or as a submodule, or as some installation during bootstrap).
Simple usecase:
cd ~
mkdir -p dotfiles && cd dotfiles
mkdir -p bash && cd bash
touch .bashrc
cd ~
stow bash # Deploys ~/.bashrc symlinked from ~/dotfiles/bash/
# More packages, version control:
cd ~/dotfiles
git init && git commit -am "Initial commit"
mkdir -p ~/dotfiles/git/
touch ~/dotfiles/git/.gitconfig
# deploy git package
cd ~ && stow git
# revert bash "package deployment"
stow -D bash
I've gone a bit overboard myself (many packages, litterate programming declaration of emacs config, Vagrant VM with Ansible deployment etc), see https://github.com/OverkillGuy/jibyconfedit: Note if you're on Debian stable, the current package is 1.x. At this point testing has moved on to 3.x. It's probably worth going straight to 3.x to avoid reworking alternates and dealing with other changes. The testing/unstable package is easy to backport (look up simple sid backport).