ayekat / localdir

Personal configuration files
65 stars 3 forks source link

Add XDG_STATE_HOME #30

Closed ayekat closed 3 years ago

ayekat commented 6 years ago

The XDG base directory specification defines XDG_DATA_HOME as a place where "user specific data files should be stored". This description is obviously a bit vague, and it fails to properly distinguish between static/immutable data (equivalent of /usr/share or /usr/lib) and mutable data for state information (equivalent of /var/lib), and has now led to this issue.

I have observed that the majority of application appear to treat it as the latter, and store mostly state/mutable data into XDG_DATA_HOME. There are a few exceptions to this, though (e.g. applications or icons, whose FHS equivalent would probably be in /usr/share), so really it's a mix of two different things.

Since I'm already in the business of extending the severely lacking XDG basedir spec with custom variables (think XDG_LOG_HOME and XDG_LIB_HOME), the proposal is thus now to add another new variable intended to properly split up these two things. The two options are:

XDG_???_HOME for immutable/static data, XDG_DATA_HOME for mutable/state data

This is the way I've treated it so far (it points to ~/.local/var/lib), and it appears to be the way most applications use it for (which is understandable, because static data is rarely generated at runtime, and is usually already present system-wide, i.e. /usr/share and /usr/lib).

If we keep it this way, we'd need to introduce a new variable name (can't think of any right now) and have it point to ~/.local/share.

XDG_DATA_HOME for immutable/static data, XDG_STATE_HOME for mutable/state data

This would be the opposite approach, and we'd need to introduce a new variable for the state information. This seems more consistent for various reasons:


Yes, you may notice that I'm in favour for the second option :-)

Links

ayekat commented 5 years ago

So now we've got XDG_DATA_HOME set to ~/.local/share and XDG_STATE_HOME set to ~/.local/var/lib.

In an ideal world, this should change everything without any problems, but we're unfortunately still using some applications where we have to hard-code the path (so there the application will continue to use ~/.local/var/lib), so nodes that want to clone the last few commits will need to create a symbolic link from one to the other (preferrably ~/.local/var/lib -> ~/.local/share) first, to avoid stuff breaking.

There are a couple of other "synchronisation points" that each need to be completed by all hosts before tackling the next:

The nodes that will synchronise for this are: chirschi, kiwi, heidubeeri, brombeeri, fyge, penrose and rainbowdash.

ayekat commented 5 years ago

There's still some applications that don't allow configuring their data location, and hardcode it to XDG_DATA_HOME, so they will remain in ~/.local/share for now. But fundamentally, switching to this new variable appears to have worked.

Closing as fixed.

ayekat commented 5 years ago

Ah yes, remark: Applications supporting XDG_STATE_HOME default to ~/.var/state if it's unset. This follows the proposal of Allison Lortie made here (EDIT: actually, it appears ~/.var/state specifically is never mentioned there, only ~/.var—my bad).

This differs from the other (more popular) proposal that uses ~/.local/state as a default, because I consider ~/.local to be the equivalent of /usr or /usr/local (thus potentially immutable), whereas state, logs and cache are all mutable, hence in a different tree (/var in the FHS).

Ideally, we could one day also have XDG_CACHE_HOME use ~/.var/cache as default (and XDG_CONFIG_HOME use ~/.local/config), but I don't believe that'll ever happen.

Buuuuuut anyway, we've got XDG_STATE_HOME!

ayekat commented 3 years ago

I just discovered that the latest XDG base directory specification has added XDG_STATE_HOME. :tada:

They default to ~/.local/state. As mentioned above, that is a bit unfortunate, but that's just a minor complaint.

Now I need to update all my applications to set the correct default value…

roosemberth commented 3 years ago

 🎉

On 26 October 2021 23:41:35 CEST, Tinu Weber @.***> wrote:

I just discovered that the latest XDG base directory specification has added XDG_STATE_HOME. :tada:

They default to ~/.local/state. As mentioned above, that is a bit unfortunate, but that's just a minor complaint.

Now I need to update all my applications to set the correct default value…

-- > You are receiving this because you are subscribed to this thread.

Reply to this email directly or view it on GitHub:

https://github.com/ayekat/dotfiles/issues/30#issuecomment-952349839 -- Sent from my Android device with K-9 Mail. Please excuse my brevity.

ayekat commented 3 years ago

Updated in be2a6135b4f149af3afa8b50ec3ad269c4dabd79.

Also updated some other projects where I knew off the top of my head that they were using XDG_STATE_HOME (totp, pacman-hacks, …). There may be other scripts floating around that still need an update, but that's not something to be tracked in this repo here, so…

Closing as fixed (again).