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.
This commit is contained in:
Jan Tojnar 2021-03-13 18:40:46 +01:00
parent 04a2b269d8
commit 1ca880a228

View file

@ -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 portals 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