Hello Michael,

yes I was also thinking it is because all the places I placed it are too late. 
Your solution looked very promising. I created 
/etc/systemd/user-environment-generators/60-local-xdg-cache.sh with the 
contents you suggested.

$ ls -l /etc/systemd/user-environment-generators/60-local-xdg-cache.sh
-rwxr-xr-x. 1 root root 202 mar 11 21:22 
/etc/systemd/user-environment-generators/60-local-xdg-cache.sh*

$ /etc/systemd/user-environment-generators/60-local-xdg-cache.sh
NSS_SDB_USE_CACHE=yesXDG_CACHE_HOME=/home/local/username/.cache

I also run

# systemctl daemon-reload

But unfortunately the results are all the same.

I am just thinking of a reboot or at least gdm restart. Should this help? I 
cannot test right now, since there are some sessions open which I cannot 
terminate without other users consent. I am not sure whether gdm restart will 
leave the sessions open.

Thanks

Marek

streda 11. marca 2026, 17:30, Michael Shaw <[email protected]> napísal/a:

> Hi Marek,
>
> Duncan hit the nail on the head here regarding how modern Plasma and systemd 
> interact. The issue you're running into is purely a timing problem.
>
> Because you're using GDM and a newer systemd-managed session, the traditional 
> shell scripts in /etc/profile.d or Plasma's env folders are simply being 
> executed too late in the login process. By the time your script runs and 
> exports those variables, systemd has already spun up the early graphical 
> components, and Mesa has already defaulted to creating mesa_shader_cache in 
> the NFS $HOME/.cache.
>
> Since your logic is dynamic (checking if the user is on the domain and if the 
> local dir is writable), static systemd environment config files won't work 
> either.
>
> The cleanest solution to beat Mesa to the punch is to use a systemd User 
> Environment Generator. These run the exact millisecond the user 
> authenticates—before GDM launches Wayland, Plasma, or Mesa.
>
> You just need to adapt your current script slightly. Instead of using export, 
> systemd generators expect you to echo the KEY=value pairs directly to 
> standard output.
>
> Create a file here: 
> /etc/systemd/user-environment-generators/60-local-xdg-cache.sh
>
> And drop this in:
>
> Bash
>
> #!/bin/bash
>
> CACHEDIR=
>
> "/home/local/
>
> ${USER}
>
> "
>
> if
>
> [[
>
> "
>
> ${HOME}
>
> "
>
> =~ ^/home/domain/.* ]];
>
> then
>
> echo
>
> "NSS_SDB_USE_CACHE=yes"
>
> if
>
> [ -w
>
> "
>
> ${CACHEDIR}
>
> "
>
> ];
>
> then
>
> echo
>
> "XDG_CACHE_HOME=
>
> ${CACHEDIR}
>
> /.cache"
>
> fi
>
> fi
>
> Make sure to make it executable, or systemd will silently ignore it: sudo 
> chmod +x /etc/systemd/user-environment-generators/60-local-xdg-cache.sh
>
> Because the systemd --user instance collects these outputs to build the 
> master environment block for the session, everything launched afterward 
> (including Mesa) will natively inherit your local XDG_CACHE_HOME right out of 
> the gate.
>
> Give that a shot and let us know if it catches the cache creation in time!
>
> Cheers,
>
> Thanks,
> V/r
> Mike Shaw
> 314-650-3097
> [email protected]
>
> On Sat, Feb 28, 2026 at 2:02 PM Marek Greško <[email protected]> 
> wrote:
>
>> Hello,
>>
>> it is worth mentioning I use Fedora 43 and gdm login manager. I am thinking 
>> about mesa_shader_cache created in $HOME/.cache location whether it is 
>> created by gdm or by early phase of plasma startup?
>>
>> Thanks
>>
>> Marek
>>
>> sobota 28. februára 2026, 11:54, Marek Greško <[email protected]> 
>> napísal/a:
>>
>>> Hello,
>>>
>>> I am trying to find out where to set XDG_CACHE_HOME in Fedora 43 for plasma 
>>> correctly.
>>>
>>> I have setup an environment where users have home directories on a nfs 
>>> share. I wanted to create local directory for XDG_CACHE_HOME. So I created 
>>> a file /etc/profile.d/nss-cache.sh containing
>>>
>>> #!/bin/bash
>>>
>>> CACHEDIR="/home/local/${USER}"
>>>
>>> if [[ "${HOME}" =~ ^/home/domain/.* ]]; then
>>> export NSS_SDB_USE_CACHE=yes
>>> if [ -w "${CACHEDIR}" ]; then
>>> export XDG_CACHE_HOME="${CACHEDIR}/.cache"
>>> fi
>>> fi
>>>
>>> But it was not doing anything. Then I found out it works when I run some 
>>> applications from the terminal, so I realized plasma does not use 
>>> /etc/profile.d. Thereafter I tried to copy the file into the 
>>> /etc/xdg/plasma-workspace/env/ directory. It mostly works. But I get the 
>>> mesa_shader_cache directory created in the $HOME/.cache and also in the 
>>> $XDG_CACHE_HOME. I think this is because the directory is created prior to 
>>> runing the script in /etc/xdg/plasma-workspace/env, and then aft4er loading 
>>> the file the directory is created again.
>>>
>>> Do you have any clue where should be the script run from to be started soon 
>>> enough I do not have the $HOME/.cache/mesa_shader_cache created?
>>>
>>> Thanks
>>>
>>> Marek

Reply via email to