Why does NixOS not set $XDG_CONFIG_HOME by default?

I noticed that $XDG_CONFIG_HOME is not set to $HOME/.config which is a convention in most modern Linux distributions AFAIK.

Is this an oversight or are user configurations also supposed to go into the nix store?

XDG_CONFIG_HOME has to default to $HOME/.config according to the specification, so I do not think setting it to that would provide any upside?

2 Likes

Hmm, you’re right. I think I got confused by the statement made by the Byobu Documentation

Note that BYOBU_CONFIG_DIR=$XDG_CONFIG_HOME/byobu if defined, and $HOME/.byobu otherwise.

It does not follow the XDG Base Directory Specification then, because it should just use $HOME/.config/byobu by default, right?

Yeah, that sounds strange. At least tmux correctly reads ~/.config/tmux/tmux.conf for me. :slight_smile:

1 Like

Yes, that’s upstream not following the specification.

1 Like

Related issue: Documentation: Set up XDG Base Directory environment variables · Issue #224525 · NixOS/nixpkgs · GitHub

1 Like

Just installed a fresh NixOS 24.05, then replaced /etc/nixos content with my personal flake-based config with home-manager. After nixos-rebuild switch the home-manager service failed to start:

…-home-manager-generation/activate: line 351: XDG_CONFIG_HOME: unbound variable

Looking at that file unveiled that it seems to be related to my Nextcloud config, because line 351 says:

nc_config_template="$XDG_CONFIG_HOME/Nextcloud/nextcloud.cfg.tmpl"

and in my home-manager config it says:

xdg.configFile."Nextcloud/nextcloud.cfg.tmpl" =

so I feel like it’s not that I messed up something there. Instead, this xdg.configFile thing in home-manager seems to rely on $XDG_CONFIG_HOME but it does not set it to anything.

So how should I solve this? Should I set the environment variable myself? Would I rather want to do that in environment.variables or in environment.sessionVariables?

While I am aware of this wiki article, I am still not sure what would help better, in this case, and in any other cases where I use this variable to refer to what really is ~/.config.


Plot twist: a sudo systemctl restart home-manager-mcn.service on the next day without rebooting or anything else went through and there is no complaint about the missing env var anymore :person_shrugging: