ayekat / localdir

Personal configuration files
65 stars 3 forks source link

Allow dotfiles repo to reside anywhere (not just $XDG_LIB_HOME/dotfiles) #12

Closed ayekat closed 5 years ago

ayekat commented 7 years ago

Currently, there are a few configuration files and shell snippets that assume that the dotfiles repository has been cloned into $XDG_LIB_HOME/dotfiles. Allowing the repo to reside anywhere else would add flexibility to the user (especially when tinkering around in the dotfiles repo itself).

ayekat commented 6 years ago

Being able to move the dotfiles repo elsewhere would also allow symlinking just the entire XDG_LIB_HOME to the one in the dotfiles repo, rather than having to do it individually.

The places where we need to get rid of the "hard path assumption" are:

I'm wondering if exporting a special DOTFILES environment variable holding a path to the dotfiles repo would solve this...

ayekat commented 5 years ago

Alright, here's a slightly crazy idea: Let's clone the dotfiles repo as ~/.local itself.

This way, we also get to set the desired structure of ~/.local (so we could create ~/.local/var/{cache,lib,log}) and wouldn't need to symlink all the stuff around (if I'm not mistaken, the only symlink required would be for .pam_environment).

I'll see if this is doable.

ayekat commented 5 years ago

Not quite as crazy as I initially feared.

Commit 584c44b implements this, and then for machines that pull it, the only thing initially breaking is just the .pam_environment symlink, which is not too much of an issue as long as we don't log out.

The required steps are then:

  1. Create the XDG_RUNTIME_DIR symlink inside the repo.
  2. For each directory in ~/.local that's not in the repo):
    1. Delete the dummy directory inside the repo.
    2. Move a given directory there and create a compatibility symlink.
    3. git checkout the deleted .gitignore file in the previously deleted dummy directory.

In the end there should only be symlinks pointing into ~/.local/lib/dotfiles/{…}. So we can (in a single line) rename ~/.local to something else and rename-move {somethingelse}/lib/dotfiles to ~/.local.

Voilà!

ayekat commented 5 years ago

I've updated this on most of my (important) hosts, and nothing has broken so far, so I'm gonna close this as a non-issue now (since we now expect the dotfiles repo to be cloned as ~/.local directly, and this directory is kinda expected to exist anyway).

Who knows, maybe in the future I will want to rename ~/.local to something else, but for the time being, I'm fine with it.