Managing Dotfiles with GNU Stow (2016)
alexpearce.me
alexpearce.me
> GitHub even has a website dedicated to different ways of organising and deploying them <https://dotfiles.github.com/>.
404, I presume https://dotfiles.github.io is what they were referring to, which is not affiliated with GitHub at all. (And there you see one of the reasons for shifting user content away from *.github.com to a different domain.)
----
This submission is presumably inspired by a current/recent discussion at https://news.ycombinator.com/item?id=27134249 on A Way To Manage Dotfiles, https://github.com/kalkayan/dotfiles, which is predicated upon another approach: using a bare Git repository with its work tree as the root of $HOME.
To be fair I also have this problem a lot administering my linux machines because they just work - until they don't. Then I have to re-learn what to do to fix the problem.
Between hourly snapshots and maintaining the same install for many years across many machines its all kind of a waste of time to me.
It's way easier for me to clone a drive or restore from backups than fuck about trying to reinstall everything how I like it.
I haven't installed Linux for years. Is it easier than dd yet?
I guess maybe if you use multiple Mac's or something it's an issue?
You can change any of the files by accessing them via your .dotfiles directory or in their normal place - they're just symlinks.
It has served me well for a few years now
For example, if you want to keep track of your whole Firefox profile's directory (without bothering adding/committing single files), in stow it's as simple as symlinking ~/.mozilla/firefox/<profile_dir>.
For programs whose configuration you know intimately this is not a problem (e.g. for bash, we all know we probably just need .bashrc), but not all programs rely on a single flat configuration file.
I have a git project called .linux-env. I can just clone it on any machine and ln my ~/.bashrc/~/.profile to it. Even works on mac.
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
source ~/.my_environment/bash/linux/.bashrc
else
source ~/.my_environment/bash/osx/.bashrc
fi
etc.If anything this would discourage more programs from adopting the xdg spec though.
I install my dotfiles globally into the system for the programs I care about with a simple shell script. Our desktops/laptops are usually all single user these days anyway, I don't see the point in trying to constrain things to a home directory. The nice things about this is that I can nuke my home directory when I feel like it, this is especially useful for programs I just want to reset without figuring out where they've littered all their configs... obviously you need to keep the dotfile repo outside of the home directory for that.
Make issues on GitHub and hope for the best. Most of the time it's already a "I don't care, won't fix".
Apparently people just don't care that I have .cache mapped to a tmpfs and they don't care that their cache stored in .config or .shitappdevelopersinc is thrashing my remote backups.
This and the security free-for-all that programs enjoy come from a simpler, more naive time in personal computing. Personally, I think one of the few things mobile OSs get right[0] is the idea that applications cannot be trusted to behave and the default should be to keep them in their own little sandbox until the user says otherwise. Launch them in their own namespace with only the things you want them to have access to mapped in or redirected as per your preference.
[0] I have issues with the implementation, but the idea is sound.
Might be.
I've been trying something similar using Apple's framework bundle layout[2] and using XDG to point config files to ~/Library/ApplicationSupport etc, but programmers know better! Just spray whatever files you need into my home dir, developers, be my guest…
[1] https://specifications.freedesktop.org/basedir-spec/latest/a...
[2] https://developer.apple.com/library/archive/documentation/Ma...
E.G: I used to "spray my files in the home dir" for my apps, until I discovered "appdirs" (https://pypi.org/project/appdirs/1.4.0/). Once I had an easy way to always has a clean and correct path for my app config/data/tmp file, I just used it.
function cd { builtin cd "${@}"; [[ -f "$PWD/.env" ]] && source "$PWD/.env"; }
To me stow seems similar, I see little to no advantage over a script/makefile that creates the symlinks and you have the complexity of another tool to learn. system.activationScripts = {
dotfiles = ''
cd /home/chriswarbo/.dotfiles || exit 1
for X in *
do
[[ -h "/home/chriswarbo/.$X" ]] && continue
[[ -e "/home/chriswarbo/.$X" ]] && {
echo "WARNING: Found ~/.$X but it's not a symlink" 1>&2
continue
}
(cd /home/chriswarbo && ln -s .dotfiles/"$X" ."$X")
done
'';
};
I've been using NixOS for many years, but my dotfiles repo goes back even further ;)Making aliases for working with `~`'s repo doesn't prevent that.
These setup also prevents zsh/bash git prompt extensions from detecting git the the home folder repo, which can be confusing, I think.
Yeah I have no issues doing this. I can count on any machine having bash and git, and I don't have to relearn how the tool works every few months.
The good: it’s a little easier that way because stow handles edge cases (e.g. existing symlink) in a sane way.
The bad: it’s annoying because stow has to be installed and it refuses to descend into subdirs. So, for example, if you want to stow type/desktop, you have to cd into type first.
Basically it could be better... but it used to be worse.
I've been going with `vcsh`[1] for 2 years now -- essentially a wrapper git that works with a home directory git repo without all the annoyances. To be fair I don't even exactly knows how it works (which may be a testament to how nicely it is done). It's just basic git commands and it doesn't create a .git in your home folder.
As simple as : $ vcsh {name_of_repo} status # check changed files $ vcsh {name_of_repo} add .. $ vcsh {name_of_repo} commit .. $ vcsh {name_of_repo} pull .. $ vcsh {name_of_repo} push ..
I settled upon chezmoi and don't have any complaints aside from it being a little bit cumbersome when merging (mostly due to my inexperience)
I’ve found it’s a lot easier to just make a single docker image of my favorite OS, load it with my dotfiles, vim plugins, etc. and then pull it down wherever I am.
Of course, this means you need Docker running on the machine. I’ve hit a couple of snags with credentials and key files, but I just end up mounting them as a volume or environment variable.
I followed this guide I found on HN, and it’s worked incredibly well.