The problem I want to solve here is how to keep track of my configuration files in a sane manner. This will accomplish versioning, ease of provisioning, and make it simple to handle configuration that GuixSD does not take care of for me (yet :). I’m going to be using git
, stow
and make
for this. These should be available in your package manager, or you could install the guix package manager and use it from there.
So first we need somewhere to store our configuration files, or dotfiles. Lets use a folder in our home directory for this: mkdir ~/dotfiles/
. Then enter that directory and initiate the git repo: cd ~/dotfiles
and git init .
Be aware that having this in a git repo means that anyone that gets access has the history of these files in your git history. So keep it private if you choose to put secret things in there. Even better is to encrypt those files with gpg or something, but thats a whole different topic.
Stow is kind of a super lightweight packager or install script. So in this directory you create folders with a name, this is what stow calls packages. So in my dotfile directory I have folders like emacs, bash, i3, etc, tmux and so on. lets take emacs and i3 as examples, here are the folder contents:
.../dotfiles/i3/
└── .config
└── i3
├── config
└── i3status.conf
.../dotfiles/emacs/
└── .emacs.d
├── ac-comphist.dat
├── config
│ ├── columns.el
│ ├── latex-conf.el
│ ├── markdown-conf.el
│ ├── newsticker-conf.el
│ ├── org-conf.el
│ ├── packages.el
│ ├── pandoc-directives.el
│ ├── recentf-sync-conf.el
│ ├── scheme-conf.el
│ ├── sunburst-theme
│ ├── ton-fx-keys.el
│ └── ui.el
├── elpa
├── .gitignore
├── init.el
└── var
└── pcache
├── ucs-utils
└── unicode-fonts
As you might notice the folder dotfile/i3/
contains what would be in my home directory root. Same with dotfiles/emacs/
.
So what does stow do? You invoke it with a directory or source; this is our dotfiles
directory and a target directory; for i3 and emacs this is our home directory; and our “packages”, that is what of the dotfiles directories do we want to “install”.
To make this easier I put this into a makefile like so:
o="/home/ton/guixsd/dotfiles"
t="/home/ton"
roothome="/root/"
st="/run/current-system/profile/bin/stow"
allpkgs="bash" "shell" "rsnapshot" "i3" "qutebrowser" "mpv" \
"htop" "uzbl" "termite" "zathura" "x" "urxvt" "tmux" "moc" \
"ssh" "lsh" "gitconfig" "fpm" "emacs" "claws-mail" "guile" \
"gnupg" "dillo" "onionshare" "gtk" "asoundrc" "mpd" "conkeror" \
"fish" "guixsrcdirenv"
rootpkgs="bash" "shell" "htop" "termite" "tmux" "emacs" "guile"
etchome="/etc/"
etcpkgs="sys-prof"
all: home
home:
${st} -d ${o} -t ${t} ${allpkgs}
root:
sudo ${st} -d ${o} -t ${roothome} ${rootpkgs}
rm del delete:
${st} -d ${o} -t ${t} -D ${allpkgs}
re reset:
${st} -d ${o} -t ${t} -R ${allpkgs}
I’ve added a few niceties like separate calls for stows reset and delete operations. All the strings in the lists for allpkgs
and rootpkgs
are folders in my dotfiles directory.
Now running make
or make home
will “stow” or install symlinks for all my configuration files that I want in my home directory; and make root
will ask for my sudo password and do the same for my root user. For example, in my ~/.config/
there is now a symlink to i3:
drwxr-xr-x 2 ton users 4096 May 9 21:23 guix
lrwxrwxrwx 1 ton users 36 Mar 13 14:13 htop -> ../dotfiles/htop/.config/htop
lrwxrwxrwx 1 ton users 32 Mar 13 14:13 i3 -> ../dotfiles/i3/.config/i3
drwxr-xr-x 3 ton users 4096 Mar 18 23:47 libreoffice
lrwxrwxrwx 1 ton users 42 Mar 13 14:13 termite -> ../dotfiles/termite/.config/termite
drwxr-xr-x 5 ton users 4096 May 12 22:24 transmission-daemon
Looking over this I realize there are now some things in here I should move into stow, there are also configurations I don’t use anymore - so they should probably go.