Dotfiles backup and bootstrap

It took me more than 18 years of using Linux, but I have finally bought a used Thinkpad, thus becoming a real Linux user. To be specific, I got a Thinkpad L13 from ~2020 with an Intel i5 CPU and 8Gb of RAM.

After I bought the laptop, it was time to set it up to my likings. I usually do this by installing a Linux distro and then manually copying my configuration files (a.k.a. dotfiles) from some messy backup folder. Since I do this quite rarely, and since when I do I also tend to pick a different distro just to try it out, I have never bothered automating this process…

…But not anymore! This time I decided to set things up properly.

OS choice: Alpine Linux

For the operating system, I chose Alpine Linux. It is an extremely simple Linux distribution that relies on minimalistic core tools - for example, it uses busybox instead of GNU coreutils and OpenRC instead of SystemD. Its package manager is incredibly fast (and it can be used declaratively) and it’s wiki is well-maintained. I am liking it a lot, but your mileage may vary - especially because it uses musl as the system C library, breaking compatibility with some pre-built applications and, notably, with video streaming platforms that rely on DRM.

Other options I considered were Void Linux, that I have happily used since 2020, OpenBSD, that I am using on my server and on my old netbook, Debian, that I am using on my gaming desktop and Slackware, the old time favorite that I used back in 2009-2013. I am not going to explain the reasons why I settled on Alpine in the end; it is mostly a matter of personal preference anyway.

Configuration files as a git repository

As for my configuration files, they are now managed via a git repository, as explained in this blog post by Drew De Vault. In short:

This way, the path of each file is preserved in the structure of the repository, and cloning it into a new system’s $HOME makes everything fall into place.

There is a small caveat with this setup: every file and directory that is directly or indirectly contained in my home, even if gitignore’d, is now part of this git repository. This includes other git repositories, and this could break certain development tools - for example, I had issues with ty ignoring all files due to them being gitignore’d by my configuration file repository.

While I was at it, I have also moved my scripts into this repository, since they are part of my desktop setup anyway.

Bootstrapping

Copying configuration files into the right place is not the only thing I need to do when I set up a new laptop. I also need to install packages, build some software from source (for example, dwm), edit some configuration files that are outside of $HOME (for example, in /etc), and so on.

I tried to automate these steps as much as I could turned them into a script. I won’t explain everything it does here, you can just read through it if you want - it is pretty self-explanatory. This script also takes care of cloning the dotfiles repository I mentioned above, so when I set up a new system I just need to download a copy of this script from my server and run it.

The script ends by printing some instruction on the remaining manual steps, such as uploading my SSH keys into some machines that I regularly access remotely and copying copying some secrets into .ssh.

Conclusion

This setup may be a bit overengineered, but it gives me a consistent way to quickly set up a new computer, and it also serves as documentation on my local configuration.