[QUESTION] How to change gnugpg default folder location? Correct "NIX" way?

Hi fellow nixers,
I’ve normally used this, which doesnt work correctly
export GNUPGHOME="${XDG_CONFIG_HOME:-$HOME/.config}/gnupg"

I guess this is not the nix way but I didn’t find relevant options for it

https://search.nixos.org/options?channel=21.11&from=0&size=50&sort=relevance&type=packages&query=gnupg

Now with this setting when I use like rofi-pass, I get Xsession gnupg error related to key not found.

Well it gets fixed by copying gnupg folder to $HOME/.gnupg but this feels weird. Is there some settings dominating in background and causing this kind of behaviour?

Not sure if this is the issue but note that when GNUPGHOME environment variable is set (for example when I want to use ~/.local/share/gnupg instead of it polluting my home directory) the socket path also changes, so the one registered by systemd will not be used. I am working around it using by overriding the socket path.

1 Like

Thanks, thats actually way more complicated than I expected. Didn’t find out how to fix it after reading the thread, but I might let .gnupg pollute my home folder when using nixos.

This has nothing to do with nix(os). gnupg will use the non-default socket when not stored in $HOME/.gnupg everywhere. Hopefully they’ll see the light and become XDG compliant but I recall reading somewhere that since it’s used on a range of OSes, there’s no incentive to deviate from the gnupg standard for the purpose of linux.