I see a lot of people talk about homemanager, but I've been happy enough with the following in my configuration.nix:
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 ;)