It is widely accepted that everyone loves new toys. For me, there is no new toy quite like a new workstation. That being said, the euphoria of a new system is often mixed with the hassle of installing your tools and getting everything just right. In order to minimize annoying setup and jump straight into playing with the new system it is best to have an automated and repeatable process for bootstrapping a new workstation. In this post I’ll detail a great tool for just that purpose, namely yadm.

At first look Yet Another Dotfiles Manager looks and sounds like it manages your dotfiles, which is true, it does, but it does so much more. One of the best features of yadm is that it provides a quick and easy mechanism to run bootstrap scripts. This means that when you need to setup a system, you can restore your trusty dotfiles, install packages, and configure tools all at the same time. Basically, if you can accomplish it in code, you can get yadm to run it for you. OK, enough with the nonsense, lets boostrap a system (followed by an explanation of the process).

git clone https://github.com/TheLocehiliosan/yadm.git ~/.yadm-project \
&& mkdir -p ~/bin  \
&& ln -s ~/.yadm-project/yadm ~/bin/yadm \
&& export PATH=$PATH:~/bin \
&& yadm clone https://github.com/cabyrd/dot-files.git

Overview


In general, the idea here is to use yadm to clone a dotfiles repository. This dotfiles repository will contain at least two types of files. First, it should contain all of your important dotfiles. Secondly, it should contain an executable that drives the bootstrapping of the system. Since you probably already hava a good handle on the dotfiles you need/use regularly, I’m only going to cover the bootstrap executable here. Yet Another Dotfiles Manager or yadm for the remainder of the post, looks at the .config/yadm/bootstrap file to determine if automatic bootstrapping is a possibility. If the .config/yadm/bootstrap file is found, yadm will prompt the user to run it. Once successfully executed, your system should be setup just as you like it.

While bootstrap can be any executable capable of setting up your system, it is worth thinking about what is available on a basic newly installed system. It makes sense to pick a ubiquitous technology likely to be found in any bare bones install. In my case, I’ve selected basic bash scripts, as almost any modern system is capable of running them with almost no setup (I’m looking at you Windows).

Repository


Hopefully you already have a repository where your dotfiles are stored, but if not, simply create one with your dotfiles in the root, and your bootstrap file at .config/yadm/bootstrap. For example, I have my dotfiles at dot-files. Below is the basic structure I’m using:

├── .bashrc
├── .bootstrap/
├── .Brewfile##os.Darwin
├── .config/
│   └── yadm/
│       └── bootstrap
├── README.md
├── .tmux.conf
└── .vimrc

yadm


Once you have a clonable repository with your bootstrap executable all we have left to do is let yadm work its magic. The basic steps are as follows:

  1. Install yadm
  2. Place yadm on your $PATH
  3. Execute yadm clone <your dotfiles repo>

Installing yadm is as simple as cloning its repo at yadm:

# git clone https://github.com/TheLocehiliosan/yadm.git ~/.yadm-project

If you have cloned yadm as shown above you can place it on the $PATH as shown below (assuming ~/bin already exists):

# ln -s ~/.yadm-project/yadm ~/bin/yadm
# export PATH=$PATH:~/bin

Now, point yadm at your dotfiles repo and away we go:

# yadm clone <dotfiles repo>

After cloning your dotfiles repository yadm should detect that you have a bootstrap script and prompt you, asking if it should be exected:

It appears that a bootstrap program exists.
Would you like to execute it now? (y/n)

Answer y and yadm will bootstrap your system.


Further Reading: