From e62c3086064adea3fee975d301e341e596e36f02 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Fri, 21 Oct 2022 13:16:49 -0700 Subject: [PATCH] xdg-utils: add patch which adds NIXOS_XDG_OPEN_USE_PORTAL env var from https://github.com/freedesktop/xdg-utils/pull/12 (cherry picked from commit b2fd1de106c1348802fd9eeecfdd0731663704fd) --- .../xdg-utils/allow-forcing-portal-use.patch | 29 +++++++++++++++++++ pkgs/tools/X11/xdg-utils/default.nix | 9 +++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/X11/xdg-utils/allow-forcing-portal-use.patch diff --git a/pkgs/tools/X11/xdg-utils/allow-forcing-portal-use.patch b/pkgs/tools/X11/xdg-utils/allow-forcing-portal-use.patch new file mode 100644 index 000000000000..0a011c05dee9 --- /dev/null +++ b/pkgs/tools/X11/xdg-utils/allow-forcing-portal-use.patch @@ -0,0 +1,29 @@ +From 835eed6a2b975fba40c3ac18b4cf5429ba9d2836 Mon Sep 17 00:00:00 2001 +From: Luna Nova +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) diff --git a/pkgs/tools/X11/xdg-utils/default.nix b/pkgs/tools/X11/xdg-utils/default.nix index 6be7e940c1f2..f54ef825fa0f 100644 --- a/pkgs/tools/X11/xdg-utils/default.nix +++ b/pkgs/tools/X11/xdg-utils/default.nix @@ -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 ];