RFC: Support Chromium in a Flatpak?
I've hacked together the required systemd units to share the Native Messaging Host as a UNIX socket in XDG_RUNTIME_DIR
, which can then be shared with the Chromium Flatpak using --filesystem=${XDG_RUNTIME_DIR}/chrome-gnome-shell
. I've set up a Flatpak extension which is mapped into the Flatpak, and directs the Native Messaging Host to basically a terrible reiplementation of netcat in Python, which connects to that Unix socket and relays the stdin/stdout.
chrome-gnome-shell_.service chrome-gnome-shell.socket org.gnome.chrome_gnome_shell.json chrome-gnome-shell
This makes extension.gnome.org work inside my Flatpak'd Chromium which will be useful on Endless and Silverblue and similar systems, provided they add chrome-gnome-shell to the host OS. I need to work with the Firefox upstream to get some extension point defined in the Flatpak but that's my next port of call.
If you agree with the approach I can propose a patch and add a flatpak/ dir to the chrome-gnome-shell build process, plus an override to add the cmdline arg to Chromium, which will place all of these files in the right locations for Flatpak to find and it should "just work".
There's another approach where we more closely unify the "inside Flatpak" and "outside Flatpak" case by using the "netcat" script, the unix socket and the systemd units in both cases. This is a bit more work but it means that we could potentially optimize a little further, by making the script support being launched "properly" by a systemd socket unit, accepting each connection through the systemd protocol rather than having systemd act as an inetd wrapper - this would effectively do the same job as the GApplication single instance does at the moment. I don't know which you think is better - having these extra systemd units just for the Flatpak case, or unifying the code paths and having the socket always be used.