summary refs log tree commit diff
path: root/pkgs/development/libraries/flatpak
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2021-03-13 18:40:46 +0100
committerJan Tojnar <jtojnar@gmail.com>2021-04-06 19:16:34 +0200
commit1ca880a2283e5510ca82068e49d417d9e6911c8c (patch)
tree19fb17400246fb9f62449373dec51e6a67336345 /pkgs/development/libraries/flatpak
parent04a2b269d8921505a2969fc9ec25c1f517f2b307 (diff)
downloadnixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.tar
nixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.tar.gz
nixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.tar.bz2
nixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.tar.lz
nixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.tar.xz
nixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.tar.zst
nixpkgs-1ca880a2283e5510ca82068e49d417d9e6911c8c.zip
flatpak: fix flatpak-spawn --clear-env
Chromium Flatpak package uses flatpak-spawn command for sandboxing
the child processes. The command comes from flatpak-xdg-utils, which is
presumably included in Flatpak runtimes. The command then calls Spawn
method of the portal.

The portal supports running commands in a clear environment when passed
FLATPAK_SPAWN_FLAGS_CLEAR_ENV flag. Unfortunately, that also clears PATH,
which is probably what prevents `flatpak` command itself from being found.

There is a relevant TODO note in the code:
https://github.com/flatpak/flatpak/blob/1.10.2/portal/flatpak-portal.c#L995-L999

For now, let’s hardcode the path to the binary.
Diffstat (limited to 'pkgs/development/libraries/flatpak')
-rw-r--r--pkgs/development/libraries/flatpak/default.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkgs/development/libraries/flatpak/default.nix b/pkgs/development/libraries/flatpak/default.nix
index 13a33f68d25..97494a5be1b 100644
--- a/pkgs/development/libraries/flatpak/default.nix
+++ b/pkgs/development/libraries/flatpak/default.nix
@@ -1,5 +1,6 @@
 { lib, stdenv
 , fetchurl
+, fetchpatch
 , autoreconfHook
 , docbook_xml_dtd_45
 , docbook-xsl-nons
@@ -93,6 +94,15 @@ stdenv.mkDerivation rec {
     # https://github.com/NixOS/nixpkgs/issues/43581
     ./use-flatpak-from-path.patch
 
+    # Hardcode flatpak binary path for flatpak-spawn.
+    # When calling the portal’s Spawn command with FLATPAK_SPAWN_FLAGS_CLEAR_ENV flag,
+    # it will clear environment, including PATH, making the flatpak run fail.
+    # https://github.com/flatpak/flatpak/pull/4174
+    (fetchpatch {
+      url = "https://github.com/flatpak/flatpak/commit/495449daf6d3c072519a36c9e4bc6cc1da4d31db.patch";
+      sha256 = "gOX/sGupAE7Yg3MVrMhFXzWHpFn+izVyjtkuPzIckuY=";
+    })
+
     # Nix environment hacks should not leak into the apps.
     # https://github.com/NixOS/nixpkgs/issues/53441
     ./unset-env-vars.patch