-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
nixos/portals: point $XDG_DESKTOP_PORTAL_DIR at the current system #186857
base: master
Are you sure you want to change the base?
Conversation
Previously, it'd be pointed at a fixed Nix store location. Doing any changes to the available portals would require logging out and in again.
9ef5fbd
to
217ba54
Compare
LGTM |
|
||
sessionVariables = { | ||
GTK_USE_PORTAL = mkIf cfg.gtkUsePortal "1"; | ||
XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals"; | ||
XDG_DESKTOP_PORTAL_DIR = "/run/current-system/sw/share/xdg-desktop-portal/portals"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! 🙂 It looks like my PR to change this to use sessionVariables
introduced this problem.
I wonder if maybe we should just set the variable directly on the systemd service as an override, rather than trying to set it globally:
diff --git a/nixos/modules/config/xdg/portal.nix b/nixos/modules/config/xdg/portal.nix
index e28ff74e5d80..c6ce43c03c3e 100644
--- a/nixos/modules/config/xdg/portal.nix
+++ b/nixos/modules/config/xdg/portal.nix
@@ -84,7 +84,16 @@ in
];
services.dbus.packages = packages;
- systemd.packages = packages;
+
+ systemd = {
+ inherit packages;
+ user.services.xdg-desktop-portal = {
+ restartIfChanged = true;
+ environment = {
+ XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
+ };
+ };
+ };
environment = {
# fixes screen sharing on plasmawayland on non-chromium apps by linking
@@ -92,10 +101,8 @@ in
# see https://github.com/NixOS/nixpkgs/issues/145174
systemPackages = [ joinedPortals ];
pathsToLink = [ "/share/applications" ];
-
- sessionVariables = {
+ variables = {
GTK_USE_PORTAL = mkIf cfg.gtkUsePortal "1";
- XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
};
};
};
That way it's more self-contained, and still updates on rebuilds.
@Atemu With your fix, do the portal changes get applied without restarting the service? It looks like the portals are loaded in main through load_installed_portals
and wouldn't be reloaded if the path changes while it's running.
@jtojnar I'm pretty sure XDG_DATA_PORTAL_DIRS
is only used by xdg-desktop-portal.service
, do you know if there would be any impact by not exporting this globally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restarting the service is a good idea but I think we should still keep the environment variable around globally to account for people's custom setups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think the environment variable is only used for dispatch by x-d-p.
I like the self-contained approach more. The possibility of breaking custom setups is unfortunate but reliance on a global variable is breaking custom configs as well, requiring hacks like this:
I have seen several people on Matrix confused by x-d-p not receiving the variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If users truly need the variable, they can actually set it themselves because xdp are now in the global share. I'll try to get it into the user service but I don't know how well that will turn out since we don't actually generate it ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For existing services, the NixOS module will just use systemd “drop-in” overrides, see https://www.freedesktop.org/software/systemd/man/systemd.unit.html.
217ba54
to
70b4fce
Compare
I integrated @kira-bruneau's feedback. However, it does not seem like the portal services are getting restarted, despite |
70b4fce
to
f859c7c
Compare
Ah, problem is not that the xdg-desktop-portal service isn't being restarted, it's that the individual portals' services aren't started or stopped. |
Oh weird, I would've thought
Oh they're not? I would've assumed that adding/removing those packages would've started/stopped the services. I definitely don't know enough about how NixOS manages it's services though. We'd still want to restart |
I think the big problem is that they're user services rather than system services. They're defined via unit files by the packages themselves and NixOS only reloads them on activation. |
I think we should go with my initial plan for now. |
f859c7c
to
217ba54
Compare
When would you expect them to be reloaded other than on activation?
Would not that also not reload the services, in addition to worsening the global contamination? |
Perhaps I wasn't clear enough, what I meant is that they're only reloaded, not started or stopped. Stopped services stay stopped and running ones continue to run.
Neither does the other solution.
There's no worsening happening here. The amount of global variables stays the same. What's changed is that one of them is slightly more flexible now. |
I meant compared to 94f69f0 |
Previously, it'd be pointed at a fixed Nix store location. Doing any changes to
the available portals would require logging out and in again.
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes