Open eddsalkield opened 4 years ago
If we follow XDG, then dotfiles folder should be somewhere in $XDG_DATA_HOME :
Since XDG_DATA_HOME default value is $HOME/.local/share, it adds two folders to create before getting dotfiles. Does it mean we need a bootstrap option (discussion initialized in #103) to initialize this ?
There's a bit of a debate to be had as to where dotfiles should go in $XDG_CONFIG_HOME/rcm/dotfiles
or $XDG_DATA_HOME/rcm/dotfiles
. I think we can safely rule out $XDG_DATA_HOME/dotfiles
, as people would not expect this location. The ambiguity being that the data to rcm in this instance are user configuration files. In my (maybe controversial) opinion, we should pick $XDG_CONFIG_HOME/rcm/dotfiles
, since people would expect backing up their $XDG_CONFIG_HOME
to back up all their dotfiles.
Either way, we do not need a bootstrap option to initalise this directory. As the specification (linked above) says:
If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700. If the destination directory exists already the permissions should not be changed. The application should be prepared to handle the case where the file could not be written, either because the directory was non-existant and could not be created, or for any other reason. In such case it may chose to present an error message to the user.
Then we just add behaviour to create dotfiles in the new location as opposed to the old.
Of course, following the specification to create files in these new locations does break backwards compatibility in at least a small way; people whose shell scripts depend on rcm initialising its files in the original directories would break. However, we would ensure that rcm continues to check the old locations, so that a standard user would notice no difference when updating to a compliant version.
Well, for rcm they are DATA and not CONFIG, that's why I used $XDG_DATA_HOME. And dotfiles folder will be amongst its own target, which is weird :)
Currently defaults are:
XDG defaults would be:
Maybe we can add a -x
option to conform to XDG if no default is found (matching a RCXDG
variable to set in your profile ?). An RCRC
variable will always have the last word if set to avoid breaking compatibility.
Let's make this work more seamlessly for XDG users.
The easiest lift is the original suggestion: look for ~/.rcrc
and ${XDG_CONFIG_HOME:-~/.config}/.rcrc
, in that order (did I get the XDG one right?). We can update rcrc(5) to document that this is the search path. I'd accept that pull request.
Once that is in place, an XDG-minded user can set DOTFILES_DIRS
in their rcrc to $XDG_DATA_HOME/rcm/dotfiles
. I'd enjoy documentation on how to XDG-ize one's rcm setup, maybe as part of rcm(7). That could be a fun documentation project if someone wants to take it on.
(In the meantime you can get far with the RCRC
environment variable.)
I think this is almost right, although we really should incorporate @mat-m's approach of separating config files from data. The logical flow would be as follows:
The .rcrc
file should be found by by:
$RCRC
~/.rcrc
${XDG_CONFIG_HOME:-~/.config}/rcm/rcrc
The dotfiles directory should be found by:
$DOTFILES_DIRS
~/.dotfiles
${XDG_DATA_HOME:-~/.local/share}/rcm/dotfiles
Using this resolution logic, new users will automatically use the XDG locations since the old default location checks will fail, and it would be backwards-compatible. No XDG-ising required!
I have a patch in the works for this - I'll submit it when I next have time to polish it up.
The easiest lift is the original suggestion: look for
~/.rcrc
and${XDG_CONFIG_HOME:-~/.config}/.rcrc
, in that order (did I get the XDG one right?). We can update rcrc(5) to document that this is the search path. I'd accept that pull request.
I think it would be insane & confusing to have ~/.rcrc
AND ${XDG_CONFIG_HOME:-~/.config}/.rcrc
, so it should become a hard error. I mean, check both locations, and exit(1) when both files exist.
Generally, +1 for the XDG compliance.
to have
~/.rcrc
AND${XDG_CONFIG_HOME:-~/.config}/.rcrc
, so it should become a hard error.
OK yes, that seems correct. Thank you for catching that.
I'm sorry for bump, but is there any progress? @eddsalkield
Since 2010, the XDG Base Directory Specification has been widely accepted, defining a standard for the locations of user configuration files. Currently, rcm checks by default for the rcrc configuration file in ~/.rcrc, which is not in alignment with the specification.
I propose that the following behaviour be implemented, to locate the default .rcrc file:
This would bring rcm into alignment with the specification, without breaking backwards compatibility.