summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authorPasquale <p3dimaria@hotmail.it>2021-12-02 23:10:08 +0100
committerPasquale <p3dimaria@hotmail.it>2022-01-26 18:45:42 +0100
commite9c491052479cfa4479748eaedd33cc56e59eb19 (patch)
tree3966298fcf6c0b458f75fd691efb98d772c902d7 /nixos/modules/config
parentb0819012c4d3bcbe68024d6da3576a7e5607606d (diff)
downloadnixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.tar
nixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.tar.gz
nixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.tar.bz2
nixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.tar.lz
nixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.tar.xz
nixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.tar.zst
nixpkgs-e9c491052479cfa4479748eaedd33cc56e59eb19.zip
nixos/xdg-portals: add portals' desktop files to XDG_DATA_DIRS
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/xdg/portal.nix35
1 files changed, 23 insertions, 12 deletions
diff --git a/nixos/modules/config/xdg/portal.nix b/nixos/modules/config/xdg/portal.nix
index 80ec3126ca5..088f2af59e2 100644
--- a/nixos/modules/config/xdg/portal.nix
+++ b/nixos/modules/config/xdg/portal.nix
@@ -1,4 +1,4 @@
-{ config, pkgs ,lib ,... }:
+{ config, pkgs, lib, ... }:
 
 with lib;
 
@@ -13,13 +13,13 @@ with lib;
 
   options.xdg.portal = {
     enable =
-      mkEnableOption "<link xlink:href='https://github.com/flatpak/xdg-desktop-portal'>xdg desktop integration</link>"//{
+      mkEnableOption "<link xlink:href='https://github.com/flatpak/xdg-desktop-portal'>xdg desktop integration</link>" // {
         default = false;
       };
 
     extraPortals = mkOption {
       type = types.listOf types.package;
-      default = [];
+      default = [ ];
       description = ''
         List of additional portals to add to path. Portals allow interaction
         with system, like choosing files or taking screenshots. At minimum,
@@ -46,25 +46,36 @@ with lib;
     let
       cfg = config.xdg.portal;
       packages = [ pkgs.xdg-desktop-portal ] ++ cfg.extraPortals;
-      joinedPortals = pkgs.symlinkJoin {
+      joinedPortals = pkgs.buildEnv {
         name = "xdg-portals";
-        paths = cfg.extraPortals;
+        paths = packages;
+        pathsToLink = [ "/share/xdg-desktop-portal/portals" "/share/applications" ];
       };
 
-    in mkIf cfg.enable {
+    in
+    mkIf cfg.enable {
 
       assertions = [
-        { assertion = (cfg.gtkUsePortal -> cfg.extraPortals != []);
-          message = "Setting xdg.portal.gtkUsePortal to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.";
+        {
+          assertion = cfg.extraPortals != [ ];
+          message = "Setting xdg.portal.enable to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.";
         }
       ];
 
-      services.dbus.packages  = packages;
+      services.dbus.packages = packages;
       systemd.packages = packages;
 
-      environment.sessionVariables = {
-        GTK_USE_PORTAL = mkIf cfg.gtkUsePortal "1";
-        XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
+      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" ];
+
+        sessionVariables = {
+          GTK_USE_PORTAL = mkIf cfg.gtkUsePortal "1";
+          XDG_DESKTOP_PORTAL_DIR = "${joinedPortals}/share/xdg-desktop-portal/portals";
+        };
       };
     };
 }