sebastiano.tronto.net

Source files and build scripts for my personal website
git clone https://git.tronto.net/sebastiano.tronto.net
Download | Log | Files | Refs | README

dotfiles.md (4570B)


      1 # Dotfiles backup and bootstrap
      2 
      3 It took me more than 18 years of using Linux, but I have finally bought
      4 a used [Thinkpad](https://en.wikipedia.org/wiki/ThinkPad), thus becoming
      5 a *real* Linux user. To be specific, I got a Thinkpad L13 from ~2020 with
      6 an Intel i5 CPU and 8Gb of RAM.
      7 
      8 After I bought the laptop, it was time to set it up to my likings. I usually
      9 do this by installing a Linux distro and then manually copying my
     10 configuration files (a.k.a. *dotfiles*) from some messy backup folder. Since
     11 I do this quite rarely, and since when I do I also tend to pick a different distro
     12 just to try it out, I have never bothered automating this process...
     13 
     14 ...But not anymore! This time I decided to set things up properly.
     15 
     16 ## OS choice: Alpine Linux
     17 
     18 For the operating system, I chose [Alpine Linux](https://alpinelinux.org/).
     19 It is an extremely simple Linux distribution that relies on minimalistic
     20 core tools - for example, it uses [busybox](https://busybox.net/) instead of
     21 [GNU coreutils](https://www.gnu.org/software/coreutils/) and
     22 [OpenRC](https://en.wikipedia.org/wiki/OpenRC) instead of
     23 [SystemD](https://en.wikipedia.org/wiki/SystemD). Its package manager is incredibly
     24 fast (and it can be used [declaratively](../2025-08-16-alpine-declarative)) and
     25 it's [wiki](https://wiki.alpinelinux.org/wiki/Main_Page) is well-maintained.
     26 I am liking it a lot, but your mileage may vary - especially because it uses
     27 [musl](https://musl.libc.org/) as the system C library, breaking compatibility
     28 with some pre-built applications and, notably, with video streaming platforms
     29 that rely on [DRM](https://en.wikipedia.org/wiki/Digital_rights_management).
     30 
     31 Other options I considered were [Void Linux](https://voidlinux.org),
     32 that I have happily used since 2020, [OpenBSD](https://www.openbsd.org),
     33 that I am using on my server and on my old [netbook](../2022-09-10-netbooks),
     34 [Debian](https://www.debian.org), that I am using on my [gaming
     35 desktop](../2023-10-15-build-time) and [Slackware](http://www.slackware.com),
     36 the old time favorite that I used back in 2009-2013. I am not going to explain
     37 the reasons why I settled on Alpine in the end; it is mostly a matter of
     38 personal preference anyway.
     39 
     40 ## Configuration files as a git repository
     41 
     42 As for my configuration files, they are now managed via a [git
     43 repository](https://git.tronto.net/config), as explained in [this blog post
     44 by Drew De Vault](https://drewdevault.com/blog/dotfiles). In short:
     45 
     46 * My home directory is a git repository.
     47 * All files are ignored by default (my `.gitignore` contains a single line: `*`).
     48 * Configuration files that I wish to track are manually added with
     49   `git add -f my_file`.
     50 
     51 This way, the path of each file is preserved in the structure of the
     52 repository, and cloning it into a new system's `$HOME` makes everything
     53 fall into place.
     54 
     55 There is a small caveat with this setup: every file and directory that is
     56 directly or indirectly contained in my home, even if `gitignore`'d, is now
     57 part of this git repository. This includes other git repositories, and this
     58 could break certain development tools - for example, I had issues with
     59 [ty](https://docs.astral.sh/ty) ignoring all files due to them being
     60 `gitignore`'d by my configuration file repository.
     61 
     62 While I was at it, I have also moved my [scripts](https://git.tronto.net/scripts)
     63 into this repository, since they are part of my desktop setup anyway.
     64 
     65 ## Bootstrapping
     66 
     67 Copying configuration files into the right place is not the only thing
     68 I need to do when I set up a new laptop. I also need to install packages,
     69 build some software from source (for example, [dwm](https://dwm.suckless.org)),
     70 edit some configuration files that are outside of `$HOME` (for example,
     71 in `/etc`), and so on.
     72 
     73 I tried to automate these steps as much as I could turned them into [a
     74 script](https://git.tronto.net/config/file/scripts/setup-config-alpine.html). I
     75 won't explain everything it does here, you can just read through it if you want -
     76 it is pretty self-explanatory. This script also takes care of cloning the dotfiles
     77 repository I mentioned above, so when I set up a new system I just need to download
     78 a copy of this script from my server and run it.
     79 
     80 The script ends by printing some instruction on the remaining manual steps,
     81 such as uploading my SSH keys into some machines that I regularly
     82 access remotely and copying copying some secrets into `.ssh`.
     83 
     84 ## Conclusion
     85 
     86 This setup may be a bit overengineered, but it gives me a consistent way to
     87 quickly set up a new computer, and it also serves as documentation on my local
     88 configuration.