Skip to content

$ cat ./posts/bash/dotfiles-are-code.mk

-rw-r--r-- 1.1K #arch #bash

Dotfiles are code

by chris · 1 min read · /bash


Dotfiles repositories collapse under their own install scripts. A Makefile and GNU Stow replace all of it with something you can read in one screen.

1. One directory per package

Stow treats each top-level directory as a package whose contents mirror the target. nvim/.config/nvim/init.lua symlinks to ~/.config/nvim/init.lua with no configuration at all.

2. A Makefile as the interface

PACKAGES := zsh nvim git tmux

install:
	stow --target=$(HOME) $(PACKAGES)

uninstall:
	stow --delete --target=$(HOME) $(PACKAGES)

.PHONY: install uninstall

3. Machine-specific overrides

Keep a host/ package per machine and add it to PACKAGES conditionally. Shared configuration stays shared; the laptop keeps its own display scaling.

4. Test the uninstall path

Run make uninstall && make install on a fresh container before trusting it. The failure mode of a dotfiles repository is always discovered on a new machine at the worst possible moment.

← cd .. fris@linux:~/blog$ man bash