xdg-utils: add patch which adds NIXOS_XDG_OPEN_USE_PORTAL env var

from https://github.com/freedesktop/xdg-utils/pull/12
This commit is contained in:
Luna Nova 2022-10-21 13:16:49 -07:00 committed by Bjørn Forsman
parent 9e23f71148
commit eaab93d638
2 changed files with 37 additions and 1 deletions

View file

@ -0,0 +1,29 @@
From 835eed6a2b975fba40c3ac18b4cf5429ba9d2836 Mon Sep 17 00:00:00 2001
From: Luna Nova <git@lunnova.dev>
Date: Wed, 7 Sep 2022 08:45:56 -0700
Subject: [PATCH] xdg-open: add $XDG_OPEN_USE_PORTAL env var
When set, the same mechanism that is used in a flatpak is used,
a dbus call to the portal. This is useful for distros with non-flatpak
wrapper or sandboxing features which require the same treatment, eg NixOS.
See https://github.com/NixOS/nixpkgs/issues/160923
---
scripts/xdg-open.in | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
index 8de839a..80d8fb3 100644
--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -508,6 +508,10 @@ if [ x"$DE" = x"" ]; then
DE=generic
fi
+if [ -n "$NIXOS_XDG_OPEN_USE_PORTAL" ]; then
+ DE=flatpak
+fi
+
DEBUG 2 "Selected DE $DE"
# sanitize BROWSER (avoid calling ourselves in particular)

View file

@ -1,7 +1,8 @@
{ lib, stdenv, fetchFromGitLab, fetchFromGitHub
, file, libxslt, docbook_xml_dtd_412, docbook_xsl, xmlto
, w3m, gnugrep, gnused, coreutils, xset, perlPackages
, mimiSupport ? false, gawk }:
, mimiSupport ? false, gawk
, withXdgOpenUsePortalPatch ? true }:
let
# A much better xdg-open
@ -30,6 +31,12 @@ stdenv.mkDerivation rec {
sha256 = "sha256-8PtXfI8hRneEpnUvIV3M+6ACjlkx0w/NEiJFdGbbHnQ=";
};
patches = lib.optionals withXdgOpenUsePortalPatch [
# Allow forcing the use of XDG portals using NIXOS_XDG_OPEN_USE_PORTAL environment variable.
# Upstream PR: https://github.com/freedesktop/xdg-utils/pull/12
./allow-forcing-portal-use.patch
];
# just needed when built from git
nativeBuildInputs = [ libxslt docbook_xml_dtd_412 docbook_xsl xmlto w3m ];