mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-19 03:14:03 +00:00
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.
This commit is contained in:
parent
f8e2ebd66d
commit
3b2f55e89f
@ -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
|
||||
|
@ -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 = [
|
||||
|
@ -0,0 +1,13 @@
|
||||
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";
|
||||
|
@ -1,33 +0,0 @@
|
||||
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…
Reference in New Issue
Block a user