about summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2023-11-18 00:35:54 +0100
committerJan Tojnar <jtojnar@gmail.com>2024-02-11 03:21:55 +0100
commit3b2f55e89f8233333b191bb7b4c9d6448a4a2d74 (patch)
tree035217ee039777ad1bf153151a27d93dfad08f24 /nixos/modules/config
parentf8e2ebd66d097614d51a56a755450d4ae1632df1 (diff)
downloadnixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.tar
nixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.tar.gz
nixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.tar.bz2
nixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.tar.lz
nixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.tar.xz
nixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.tar.zst
nixlib-3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.zip
xdg-desktop-portal: Use custom variable for finding portals
x-d-p only looks for portal definitions in one of two places:
- datadir (which we cannot install anything to, since Nix packages are immutable)
- when `XDG_DESKTOP_PORTAL_DIR` environment variable is set, the path specified therein
  (meant for tests, disables looking for portal configuration anywhere else)

Let’s introduce our own `NIX_XDG_DESKTOP_PORTAL_DIR` environment variable
that will only control the portal definitions lookup.
We will not use it for searching for configuration
because it would require looking in the parent directory
and `XDG_CONFIG_DIRS` variable is sufficient for us.
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/xdg/portal.nix24
1 files changed, 10 insertions, 14 deletions
diff --git a/nixos/modules/config/xdg/portal.nix b/nixos/modules/config/xdg/portal.nix
index 07d4fa76c2e8..a1540d86fa75 100644
--- a/nixos/modules/config/xdg/portal.nix
+++ b/nixos/modules/config/xdg/portal.nix
@@ -119,19 +119,12 @@ in
     let
       cfg = config.xdg.portal;
       packages = [ pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;
-      configPackages = cfg.configPackages;
 
       joinedPortals = pkgs.buildEnv {
         name = "xdg-portals";
         paths = packages;
         pathsToLink = [ "/share/xdg-desktop-portal/portals" "/share/applications" ];
       };
-
-      joinedPortalConfigs = pkgs.buildEnv {
-        name = "xdg-portal-configs";
-        paths = configPackages;
-        pathsToLink = [ "/share/xdg-desktop-portal" ];
-      };
     in
     mkIf cfg.enable {
       warnings = lib.optional (cfg.configPackages == [ ] && cfg.config == { }) ''
@@ -158,17 +151,20 @@ in
       systemd.packages = packages;
 
       environment = {
-        # fixes screen sharing on plasmawayland on non-chromium apps by linking
-        # share/applications/*.desktop files
-        # see https://github.com/NixOS/nixpkgs/issues/145174
-        systemPackages = [ joinedPortals ];
-        pathsToLink = [ "/share/applications" ];
+        systemPackages = [
+          joinedPortals
+        ] ++ cfg.configPackages;
+        pathsToLink = [
+          # Upstream desktop environment portal configurations.
+          "/share/xdg-desktop-portal"
+          # .desktop files to register fallback icon and app name.
+          "/share/applications"
+        ];
 
         sessionVariables = {
           GTK_USE_PORTAL = mkIf cfg.gtkUsePortal "1";
           NIXOS_XDG_OPEN_USE_PORTAL = mkIf cfg.xdgOpenUsePortal "1";
-          XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
-          NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR = mkIf (cfg.configPackages != [ ]) "${joinedPortalConfigs}/share/xdg-desktop-portal";
+          NIX_XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
         };
 
         etc = lib.concatMapAttrs