nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.28k stars 1.68k forks source link

Add configuration to force using portal in xdg-open #4740

Open dyfrgi opened 7 months ago

dyfrgi commented 7 months ago

xdg-open is a utility program which is supposed to find a program to handle a URL. After installing a gui program via home-manager in an FHS environment, for instance logseq on Debian 12, the gui program may not be able to open URLs. Many such programs (including logseq) call xdg-open to handle URLs. xdg-open then tries to detect the desktop environment that the user is running in and calls a program, e.g. gio open on Gnome. However, this may fail due to LD_LIBRARY_PATH being set by a wrapper for programs installed with home-manager so that they will find the Nix libraries rather than system libraries.

In NixOS, this is also a problem when opening an FHS app. This was solved (or at least worked around) with https://github.com/NixOS/nixpkgs/pull/197118. It is then possible to set xdg.portal.xdgOpenUsePortal in a NixOS config to add the enabling variable to session variables. However, this setting isn't available in home-manager as it's part of a NixOS module, not the xdg-utils package itself.

Home Manager should have a variable which both adds NIXOS_XDG_OPEN_USE_PORTAL = 1 to sessionVariables and installs xdg-utils. It's possible that this should be set by default, though I'm not sure - you can see in https://github.com/NixOS/nixpkgs/issues/160923 that there's discussion currently about whether to turn this on by default for NixOS. Not setting it by default will leave users to find the flag for themselves after installing an app and finding that it doesn't work. Setting it by default might instead break some people in configurations that depend on it not being set by default. Certainly any backport should have it default off, but for versions where breaking changes are allowed I think it should be default on.

Misterio77 commented 7 months ago

Added by https://github.com/nix-community/home-manager/pull/4707

stale[bot] commented 4 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.