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

Add nix dirs to XDG_DATA_DIRS so it can pick up .desktop files for GUI apps #614

Closed
chewblacka opened this issue Aug 27, 2023 · 3 comments
Closed

Comments

@chewblacka
Copy link

chewblacka commented Aug 27, 2023

The DS Nix installer is close to becoming a first-class citizen for installing nix packages on non-NixOS distributions. One current issue though is that .desktop files for GUI apps are not auto-picked-up by the DE. This is easy to rectify though. Simply add a file to etc/profile.d/ containing the following line:

export XDG_DATA_DIRS="${HOME}/.nix-profile/share:/nix/var/nix/profiles/default/share:${XDG_DATA_DIRS}"

I called my file nix-xdg-data-dirs.sh but /etc/profile.d/ already contains nix.sh which calls /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh so the XDG_DATA_DIRS line could simply be added to this latter file by the installer.

Using the syntax of the existing file nix-daemon.sh, I believe the correct line to add to it would be:

export XDG_DATA_DIRS="$NIX_LINK/share:/nix/var/nix/profiles/default/share:$XDG_DATA_DIRS"

This could go directly after the existing export PATH command.
Many thanks for the great ongoing work!

@chewblacka
Copy link
Author

Oops I see that the files I referenced above are part of the base nix install and not part of the DS installer. I guess this means the DS installer could either install a completely new file in /etc/profile.d (e.g. nix-xdg-data-dirs.sh) or this issue needs to be escalated upstream to nix?

@Hoverbear
Copy link
Contributor

I think that's a solid idea! Since this installer doesn't own /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh, I believe it would be best to recommend this upstream?

@chewblacka
Copy link
Author

chewblacka commented Sep 3, 2023

Many thanks for the reply @Hoverbear
I've done some digging, and apparently the decision not to include XDG_DATA_DIRS in the nix installer is by design not omission. There are a few PRs discussing this but the main one is this:

NixOS/nix#2443

where Elco says:

"I feel that Nix on non-NixOS systems should pollute the user's environment as little as necessary, to minimize the probability that installing a Nix package breaks the host system."

I don't think that modifying XDG_DATA_DIRS in the way I have suggested would break the host system, but I don't know that 100% either. Perhaps a more conservative approach would be to append the nix paths at the end, rather than prepend? In any case, I guess it will remain a user-guided manual intervention. Closing as not a DS issue. Many thanks!

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