flathub/org.gnu.emacs

Support SDK extensions

Closed this issue · 4 comments

muep commented

There does not seem to be a convenient way to do this automatically, but the vscode flatpak has some preparations which make it possible to use extensions of the org.freedesktop.SDK runtime:

At least the first bit should be reasonably easy to add to the Emacs flatpak, and this would substantially increase the number of things that can be immediately done within the flatpak'ed Emacs.

The second bit would also be nice, but I am not sure of how easy it is to do that. If IDE-ish tools in flathub all converge on a similar mechanism, it is not absolutely required for each and every tool to have this document.

As requested in flathub/org.freedesktop.Sdk.Extension.golang#26, I use extensions in the Emacs flatpak already, so just giving info on that. It's fairly straightforward, at least for my usage -- just add the correct stuff to your environment and have the extension installed to the correct flatpak context (system or user, whatever you've got Emacs flatpak installed as). E.g. for the Golang extension, I add /usr/lib/sdk/golang/bin/ to my $PATH, and then I also set export GOROOT=$(go env GOROOT 2>&1 /dev/null) in my ~/.bashrc also, so that it's set correctly for me no matter what context I'm in -- my host machine, a flatpak such as Emacs, or a containers/toolbox or other container. I believe that's it! 🙂

Another thing that I just found out recently (and the point of flathub/org.freedesktop.Sdk.Extension.golang#26) is that Emacs and your extensions need to be built for the same freedesktop platform base.

muep commented

Thanks @grdryn .

I think the Emacs flatpak should have some kind of a shell wrapper to set up these similarly to what vscode does, but until that is available, it seems to me that setups such as in your bashrc are needed.

To avoid changing my environment on the host side, I added these to my .emacs.d/init.el:

(setenv "GOROOT" "/usr/lib/sdk/golang")
(setenv "PATH" (concat (getenv "PATH") ":/usr/lib/sdk/golang/bin"))
muep commented

Built from commit e66a72a above, things seem to work quite OK. If I launch like this:

env FLATPAK_ENABLE_SDK_EXT=openjdk11 flatpak run --command=/app/bin/wrapped-emacs org.gnu.emacs

I can at least use M-x shell and see a working java inside the sandbox.

As a bonus, there is the first run help file shown on first run as well. These had some templating already in place, so their content even seems pretty reasonable for an Emacs.

Some discrepancies to be handled before this is ready for merging in:

  • Use the wrapper script by default
  • FLATPAK_VSCODE_ENV env variable
  • File names:
    • ${XDG_CONFIG_HOME}/flatpak-vscode-first-run
    • ${XDG_CONFIG_HOME}/flatpak-vscode-sdk-update-20.08
    • /app/share/vscode-flatpak-wrapper

The script also has some function names referring to vscode, but those are not so much user-visible that it would be absolutely necessary to change them.

Some changes to make things more robust:

  • Don't iterate /app/tools since we are not going to place things there
muep commented

This should have been addressed once #37 got merged in.