Follow XDG Base Directory Specification
The XDG Base Directory Specification specifies that:
There is a single base directory relative to which user-specific data files should be written. This directory is defined by the environment variable $XDG_DATA_HOME.
Currently, hydroxide stores everything in $XDG_CONFIG_HOME/hydroxide, which is a step in the right direction, but mixes user configuration in with runtime data.
I propose that we should keep the user's config files where they currently are, but separate out the *.db files into $XDG_DATA_HOME/hydroxide.
Upon reflection, I have somewhat changed my mind on this: since hydroxide actually runs a system-wide service (the services it serves are accessible anywhere on the localhost), it makes much more sense to run hydroxide at a system, rather than a user level.
Therefore, the configuration files should actually be stored in /etc/hydroxide, and the data files should be in /var/lib/hydroxide.
We can keep the XDG directories as a fallback for backwards compatibility. This change would need to be documented in the README.
Sometimes it makes sense to run hydroxide as a system-wide service, sometimes it makes sense to run it as the current user. The services may not always be accessible from anywhere on localhost, e.g. if we're going to support Unix sockets at some point.
I agree hydroxide should stop using $XDG_CONFIG_HOME/hydroxide for the DBs. In fact, I think everything would be better off living in $XDG_DATA_HOME right now?
Sometimes it makes sense to run hydroxide as a system-wide service, sometimes it makes sense to run it as the current user.
Makes sense!
Therefore, to support running hydroxide as the current user, all *.db files and other such data files should indeed go in $XDG_DATA_HOME/hydroxide. However, config files (such as 'auth.json') should remain in $XDG_CONFIG_HOME/hydroxide.
To support running hydroxide as a system-wide service, I propose that two flags are added (say, --config-dir and --data-dir, perhaps also abbreviated to -c and -d), allowing the user to specify the configuration and data locations themselves. A system service file can simply set these to /var/lib/hydroxide and /etc/hydroxide respectively itself.
config files (such as 'auth.json') should remain in $XDG_CONFIG_HOME/hydroxide.
auth.json is not really a config file. It's more of a user database.
allowing the user to specify the configuration and data locations themselves
Yeah, that sounds sensible.
As an alternative, if https://github.com/emersion/hydroxide/issues/123 is implemented (would be useful for a system service anyways), we could just have a flag for the config file, and specify the data dir in the config file.
auth.json is not really a config file. It's more of a user database.
That sounds fair enough, especially since user credentials aren't directly stored in or manipulated from the file.
As an alternative, if #123 is implemented (would be useful for a system service anyways), we could just have a flag for the config file, and specify the data dir in the config file.
This could also work, but one nice thing about hydroxide is that it's so simple that very little configuration is needed. Adding a new flag (now just --data-dir, or -d) seems like the more simple approach to me at this point.