Clojure should not rely only on the XDG_CONFIG_HOME
environment variable to follow the XDG standard.
In an XDG System, XDG_CONFIG_HOME
exists to allow users to override the default which is ~/.config
.[1]
Defining XDG_CONFIG_HOME
in my XDG system as ~/.config
is redundant, but I’m forced to do it by Clojure if I want to keep all my configuration files in ~/.config
.
The order for “User - cross-project configuration (typically tools)” according to the Clojure reference is:
- If $CLJ_CONFIG is set, then use $CLJ_CONFIG (explicit override)
- If $XDG_CONFIG_HOME is set, then use $XDG_CONFIG_HOME/clojure (Freedesktop conventions)
- Else use $HOME/.clojure (most common)
But I think the tools should find another way to determine if the System is an XDG System. Let’s say it exists, step 2 should be something like:
- If an XDG System, use $XDG_CONFIG_HOME if set or $HOME/.config/clojure
That predicate “is an XDG System” could be implemented (redundantly) as: Is $XDG_CONFIG_HOME set or $HOME/.config exists?.
So another more specific way to implement 2:
- XDG_CONFIG_HOME if set or $HOME/.config/clojure if exists.
And if it is a clean system, with no preexisting ~/.clojure
nor ~/.config/clojure
, the creation of .config/clojure
should take precedence over .clojure
if Clojure can tell if the System is an XDG System.
End of my OPINION (just highlighting it is just an Opinion). ← Opinion
[1] “If $XDG_CONFIG_HOME
is either not set or empty, a default equal to $HOME
/.config should be used” - Environment variables