Loading nixos/modules/config/xdg/portal.nix +8 −20 Original line number Diff line number Diff line Loading @@ -119,19 +119,6 @@ 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 == { }) '' Loading @@ -158,17 +145,18 @@ 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 = packages ++ cfg.configPackages; pathsToLink = [ # Portal definitions and 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 = "/run/current-system/sw/share/xdg-desktop-portal/portals"; }; etc = lib.concatMapAttrs Loading pkgs/development/libraries/xdg-desktop-portal/default.nix +4 −5 Original line number Diff line number Diff line Loading @@ -54,11 +54,10 @@ stdenv.mkDerivation (finalAttrs: { # Allow installing installed tests to a separate output. ./installed-tests-path.patch # `XDG_DESKTOP_PORTAL_DIR` originally was used for upstream tests. But we are making use # of this in the NixOS module, this actually blocks any configs from being loaded since # configs are not expected to be placed in a portal implementation or even under the # `share/xdg-desktop-portal/portals/` path. ./separate-env-for-portal-config.patch # Look for portal definitions under path from `NIX_XDG_DESKTOP_PORTAL_DIR` environment variable. # While upstream has `XDG_DESKTOP_PORTAL_DIR`, it is meant for tests and actually blocks # any configs from being loaded from anywhere else. ./nix-pkgdatadir-env.patch ]; nativeBuildInputs = [ Loading pkgs/development/libraries/xdg-desktop-portal/nix-pkgdatadir-env.patch 0 → 100644 +13 −0 Original line number Diff line number Diff line diff --git a/src/portal-impl.c b/src/portal-impl.c index 85b3a23..6d43636 100644 --- a/src/portal-impl.c +++ b/src/portal-impl.c @@ -275,6 +275,8 @@ load_installed_portals (gboolean opt_verbose) /* We need to override this in the tests */ portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + if (portal_dir == NULL) + portal_dir = g_getenv ("NIX_XDG_DESKTOP_PORTAL_DIR"); if (portal_dir == NULL) portal_dir = DATADIR "/xdg-desktop-portal/portals"; pkgs/development/libraries/xdg-desktop-portal/separate-env-for-portal-config.patchdeleted 100644 → 0 +0 −33 Original line number Diff line number Diff line diff --git a/src/portal-impl.c b/src/portal-impl.c index 0fa9682e..99f379dc 100644 --- a/src/portal-impl.c +++ b/src/portal-impl.c @@ -433,8 +433,7 @@ load_portal_configuration (gboolean opt_verbose) desktops = get_current_lowercase_desktops (); - /* We need to override this in the tests */ - portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + portal_dir = g_getenv ("NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR_OVERRIDE"); if (portal_dir != NULL) { @@ -464,6 +463,18 @@ load_portal_configuration (gboolean opt_verbose) if (load_config_directory (SYSCONFDIR "/" XDP_SUBDIR, desktops, opt_verbose)) return; + portal_dir = g_getenv ("NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR"); + + if (portal_dir == NULL) + /* We need to override this in the tests */ + portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + + if (portal_dir != NULL) + { + if (load_config_directory (portal_dir, desktops, opt_verbose)) + return; + } + /* $XDG_DATA_HOME/xdg-desktop-portal/(DESKTOP-)portals.conf * (just for consistency with other XDG specifications) */ g_clear_pointer (&user_portal_dir, g_free); Loading
nixos/modules/config/xdg/portal.nix +8 −20 Original line number Diff line number Diff line Loading @@ -119,19 +119,6 @@ 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 == { }) '' Loading @@ -158,17 +145,18 @@ 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 = packages ++ cfg.configPackages; pathsToLink = [ # Portal definitions and 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 = "/run/current-system/sw/share/xdg-desktop-portal/portals"; }; etc = lib.concatMapAttrs Loading
pkgs/development/libraries/xdg-desktop-portal/default.nix +4 −5 Original line number Diff line number Diff line Loading @@ -54,11 +54,10 @@ stdenv.mkDerivation (finalAttrs: { # Allow installing installed tests to a separate output. ./installed-tests-path.patch # `XDG_DESKTOP_PORTAL_DIR` originally was used for upstream tests. But we are making use # of this in the NixOS module, this actually blocks any configs from being loaded since # configs are not expected to be placed in a portal implementation or even under the # `share/xdg-desktop-portal/portals/` path. ./separate-env-for-portal-config.patch # Look for portal definitions under path from `NIX_XDG_DESKTOP_PORTAL_DIR` environment variable. # While upstream has `XDG_DESKTOP_PORTAL_DIR`, it is meant for tests and actually blocks # any configs from being loaded from anywhere else. ./nix-pkgdatadir-env.patch ]; nativeBuildInputs = [ Loading
pkgs/development/libraries/xdg-desktop-portal/nix-pkgdatadir-env.patch 0 → 100644 +13 −0 Original line number Diff line number Diff line diff --git a/src/portal-impl.c b/src/portal-impl.c index 85b3a23..6d43636 100644 --- a/src/portal-impl.c +++ b/src/portal-impl.c @@ -275,6 +275,8 @@ load_installed_portals (gboolean opt_verbose) /* We need to override this in the tests */ portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + if (portal_dir == NULL) + portal_dir = g_getenv ("NIX_XDG_DESKTOP_PORTAL_DIR"); if (portal_dir == NULL) portal_dir = DATADIR "/xdg-desktop-portal/portals";
pkgs/development/libraries/xdg-desktop-portal/separate-env-for-portal-config.patchdeleted 100644 → 0 +0 −33 Original line number Diff line number Diff line diff --git a/src/portal-impl.c b/src/portal-impl.c index 0fa9682e..99f379dc 100644 --- a/src/portal-impl.c +++ b/src/portal-impl.c @@ -433,8 +433,7 @@ load_portal_configuration (gboolean opt_verbose) desktops = get_current_lowercase_desktops (); - /* We need to override this in the tests */ - portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + portal_dir = g_getenv ("NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR_OVERRIDE"); if (portal_dir != NULL) { @@ -464,6 +463,18 @@ load_portal_configuration (gboolean opt_verbose) if (load_config_directory (SYSCONFDIR "/" XDP_SUBDIR, desktops, opt_verbose)) return; + portal_dir = g_getenv ("NIXOS_XDG_DESKTOP_PORTAL_CONFIG_DIR"); + + if (portal_dir == NULL) + /* We need to override this in the tests */ + portal_dir = g_getenv ("XDG_DESKTOP_PORTAL_DIR"); + + if (portal_dir != NULL) + { + if (load_config_directory (portal_dir, desktops, opt_verbose)) + return; + } + /* $XDG_DATA_HOME/xdg-desktop-portal/(DESKTOP-)portals.conf * (just for consistency with other XDG specifications) */ g_clear_pointer (&user_portal_dir, g_free);