Machine Specific Config#
Machine specific dotfiles config is configured via chezmoi templates. This currently only applies to bashrc files.
Custom ~./.gitconfig as the global config#
I use this to keep home and work config separate.
It is named
symlink_dot_gitconfig.tmplwhich indicates that it should by a symlink.The symlink destination is
~/.gitconfigand the target comes from the contents of the template file using theusernamevariable..gitconfig_{{ .chezmoi.username }}
So on my home PC, we get the following
/home/vvnraman/.gitconfig -> .gitconfig_vvnraman
At work, I always have a separate branch exactly 1 commit ahead of
originwhich contains the the work specific gitconfig file, which~/.gitconfigpoints to.
Custom bashrc-custom config#
We have a dot-bash/symlink_bashrc-custom-machine.tmpl template file in our
source directory. This file will exist in the desitnation directory as
a regular symlink named dot-bash/bashrc-custom-machine.
This symlink is sourced in our dot-bash/profile as follows
source_script "$HOME/dot-bash/bashrc-custom-machine"
The content of this template file determines where it points to. Currently it contains the following template
bashrc-custom-{{ .chezmoi.hostname }}_{{ .chezmoi.osRelease.id }}_{{ .chezmoi.osRelease.versionID }}
The symlink in the destination directory points to the resolved file name based on the values of those template variables. On my personal laptop, inside WSL2 Ubuntu 20.04, this resolves to the following name:
bashrc-custom-USH-LP19-RIX1_ubuntu_20.04
This means that we have the following link available on my personal laptop
$ ls -l dot-bash/bashrc-custom-machine
lrwxrwxrwx 1 vvnraman vvnraman 40 May 10 22:04 dot-bash/bashrc-custom-machine -> bashrc-custom-USH-LP19-RIX1_ubuntu_20.04
This allows us to have custom configuration in this file without affecting how the dotfiles affects the other machines where they get cloned.