A Version Controlled $HOME

Just as mentioned in the overview of vcsh, I have tried putting all my important configuration files in a single repository and then moved to a symbolic link collection. It became a pain to keep my accounts set up to taste so I figured I'd give vcsh a try.

It took me a while to understand the role that myrepos (formerly mr) played in the whole story, though. As using vcsh tends to result in a largish number of repositories, a tool like mr comes in very handy. Actually, you may even end up maintaining most of your repositories with it, but let's keep that for another post.

In the following, I will bootstrap vcsh to use mr under the hood to manage all configuration "modules" that I will sooner or later put under version control. During the bootstrap, I will create one module to manage the configuration of all VCS repositories that I am tracking. Many will be using vcsh but you can track any type of VCS repository that mr supports.

Configurations of tracked repositories are kept in available.d/ so that I can easily share that among my accounts by making a symlink to my-repos module in enabled.d/.

First I initialize my-repos module and add an mr configuration file that reads all enabled configuration snippets, if any.

vcsh init my-repos
cat << EOF > $HOME/.mrconfig
include = cat \${XDG_CONFIG_HOME:-\$HOME/.config}/my-repos/enabled.d/* 2>/dev/null || true
vcsh my-repos add -f $HOME/.mrconfig
vcsh my-repos commit

Next, I add a remote on GitLab and push my-repos repository using vcsh so I can easily share it across accounts.

vcsh my-repos remote add origin git@gitlab.com:dotter/my-repos.git
vcsh my-repos push -u origin master

Then, I set up the infra-structure to support the distinction between available.d/ and enabled.d/ repositories.

mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/my-repos/available.d
mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/my-repos/enabled.d

Registering repositories via mr will add a stanza in $HOME/.mrconfig which is not what I want. The my-repos module should have its own configuration file snippet, so I create one and add it to the module:

cat << EOF > ${XDG_CONFIG_HOME:-$HOME/.config}/my-repos/available.d/my-repos.vcsh
checkout = vcsh clone https://gitlab.com/dotter/my-repos.git my-repos
vcsh my-repos add -f ${XDG_CONFIG_HOME:-$HOME/.config}/my-repos/available.d/my-repos.vcsh
vcsh my-repos commit

Finally, I activate my-repos module and push the latest commit to the upstream repository with mr.

ln -s ../available.d/my-repos.vcsh ${XDG_CONFIG_HOME:-$HOME/.config}/my-repos/enabled.d
mr push

After this, you just make mr configuration snippets for all of your repositories available.d/ and simply mark the ones you need as enabled.d/ on each of your accounts. Remember, they don't have to be vcsh repositories.