Skip to content
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

Nix shell environment should append to $XDG_DATA_DIRS default value if the variable is not defined #6098

Open
TotallyNotChase opened this issue Feb 14, 2022 · 0 comments

Comments

@TotallyNotChase
Copy link

Is your feature request related to a problem? Please describe.
According to the spec $XDG_DATA_DIRS defaults to /usr/local/share:/usr/share if it's not explicitly set. So consider a barebones config'd system where $XDG_DATA_DIRS is not set. Most apps still work just fine since they just use the default. But whenever I do nix-shell, it tries to append the nix store specific data dir to the non existent $XDG_DATA_DIRS variable - so now $XDG_DATA_DIRS gets set to a value that just contains the nix store path and not the default path.

This means that when I start up a gtk app from my own system that is not included within the nix derivation, I get errors like "GSETTINGS schemas are not installed". I realize that I could just include every single dependency in the nix derivation to fix this. But I'd rather prefer using what I already have on my system.

Example:-
I'm on an arch linux machine with minimal config. $XDG_DATA_DIRS is not defined in my environment. But I do have all the schemas needed in /usr/share/. So VSCode works fine here. However, after I do nix-shell with a minimal shell.nix-

{ pkgs ? import <nixpkgs> {} }:
  pkgs.mkShell {
    nativeBuildInputs = [ ];
}

I notice that $XDG_DATA_DIRS is now set to /nix/store/<hash>-patchelf-0.14.3/share. I fire up VSCode and it just dies whenever it needs to access GSETTINGS schemas.

Describe the solution you'd like
Prior to appending paths to $XDG_DATA_DIRS, if the variable is not defined already, it should be set to /usr/local/share:/usr/share first.

Describe alternatives you've considered
I could add gtk dependencies and wrapGAppHook to the nix shell. Or, more likely, I could define $XDG_DATA_DIRS to its default value explicitly. So that nix appends to that default value, preserving both the nix store path and the system path.

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants