-
-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation: Set up XDG Base Directory environment variables #224525
Comments
I have been using this
for a number of years now and never noticed any issue. |
|
It works for me: I actually use fish and always log in a tty before starting the graphical session. I'm quite surprised to hear you say this. |
I get this error after logging in:
|
I'll describe the setup and symptoms in more detail. The computer I'm using has two users. My user has set The other user however uses the default shell. When logging in via TTY, they have no problem. However, launching Plasma Wayland (and not X11) through SDDM, causes it to not load. Looking at @rnhmjoj Do you replicate these behaviors with the settings I just described? |
No, I can't reproduce your issue. I just tried this: nix-build -E '(import <nixpkgs/nixos> { configuration = { pkgs, ... }:
{ users.users.vm = {
password = "vm";
isNormalUser = true;
shell = pkgs.fish;
};
environment.sessionVariables.XDG_CONFIG_HOME = "$HOME/etc";
};
}).vm' Running the VM and logging in: I also tried without I would try to pinpoint the issue by removing parts of your configuration, or starting with nothing and adding piece by piece. |
Anyway, I would be in favour of a more user friendly option to set these variables. There are already options like |
So, replacing |
Those other options are required to have a XDG compliant system. But you should never need to set those variables unless you want to override the defaults so having the option under |
Yes, that's exactly the reason to have this option. I'm not sure what non-compliant applications have to do with this: they are not going to read the variables anyway. |
They are non-compliant in that they do not use the implicit default values as described in the basedir spec. Maybe we could call them “partially compliant” but I felt that was long enough and it sounds a bit like “partially pregnant”. |
I've never come across anything like this. Anyway, I think the point of these variables is to customise the default locations of the XDG directories, without setting hunders of application-specific variables. For example, I like them to be visible so I rename them to etc, bin, var. |
For the record, these are the defaults mentioned in the XDG Base Directory Specification: {
environment.sessionVariables = {
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_DIRS = "/etc/xdg";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_DIRS = "/usr/local/share/:/usr/share/";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_STATE_HOME = "$HOME/.local/state";
};
} (Please note ❯ nix repl --file '<nixpkgs/nixos>'
nix-repl> pkgs.lib.attrsets.filterAttrs (name: value: pkgs.lib.strings.hasPrefix "XDG_" name) config.environment.sessionVariables
{
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_DIRS = "/etc/xdg";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_DIRS = "/nix/store/vihazwfjqbwl76gzpsj3r9nr5bbsmw4q-gnome-mimeapps/share:/nix/store/nh03g2vz8by412ywv1kbqqlnrzk9h7cm-desktops/share";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_DESKTOP_PORTAL_DIR = "/nix/store/bif15j4523chg85ydf99d7mjjmmsk4ss-xdg-portals/share/xdg-desktop-portal/portals";
XDG_STATE_HOME = "$HOME/.local/state";
} You might want to omit or Please let me know if there are any omissions or errors. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/why-does-nixos-not-set-xdg-config-home-by-default/45296/6 |
Problem
XDG Base Directories are environment variables that allow to organize the location of configuration, data, etc. in the home directory.
Even with the default values, they make the user's
$HOME
much cleaner: for example, Git by default stores its configuration in~/.gitconfig
, but withXDG_CONFIG_HOME
set then it will be stored inXDG_CONFIG_HOME/git/config
.The problem is: in NixOS, how does one set up these environment variables declaratively?
A solution could be Home Manager, which has the option
programs.xdg.enable
(which needs to be combined withprograms.<shell>.enable
in order to work). However, using Home Manager for such a simple thing is a bit overkill.Another solution, according to the Arch Wiki, would appear to be:
However,
environment.sessionVariables
doesn't support@{HOME}
. You could use\${HOME}
instead, however it may not be initialized when pam_env sets up these environment variables. It happens for example when logging in via TTY to a Fish shell.Basically, every way I found to set up these variables has a flaw.
Proposal
Maybe creating some NixOS options specifically for setting up the XDG Base Directories?
Checklist
The text was updated successfully, but these errors were encountered: