tldr; to do “normal” development work in vscode via Silverblue change your integrated terminal to flatpak-spawn and your integrated terminal args to [ "--host", "toolbox", "enter" ] to set your default toolbox as your default terminal.

I’ve been quite interested in the Fedora project’s Silverblue for a while now, but have been hesitant to use it. For those who don’t know, Silverblue is a version of Fedora Linux that the user (by default and design) cannot change the operating system. The operating system is updated atomically, much like how your phone will generally download an update and then do the update for you in one go. Also, by default, all applications are installed via containers, and in particular, flatpak containers.

I’ve tried installing Silverblue in a few virtual machines to test it out to see if it would be viable for me to use as my operating system. My main requirements have been:

I’m glad to say, after much experimentation, that nearly all of these things are available! I say nearly because, at the time of this writing, vscodium isn’t available as a flatpak and the maintainer of it’s equivalent (vscode-oss on flathub) no longer has time to maintain it. That being said, there is a PR that looks like it will be merged soon to add VSCodium to flathub. It seems very likely that it will be added.

The Problem

Flatpak is a container platform which isolates what apps can and cannot do. This causes problems when you try and develop using command line tools that exist outside of the container, from inside the container. When you open the integrated terminal for vscode, you are inside the container (by default) and cannot access the command line tools stored on the host.

Silverblue has a container command line development tool called toolbox. This allows you to install whatever cli development tools you want in it’s own container. The trick, in this scenario, is accessing your toolbox container from within the vscode container.

The Solution

The flathub maintainers have given vscode the --talk-name=org.freedesktop.Flatpak permission which allows you to run the flatpak-spawn command. This command allows you to run commands on the host system from inside of the contained application (effectively breaking containment). We can use this command to setup our toolbox as our default shell.

Setup toolbox as your Shell

First, setup toolbox. Next you’ll need to change two fields in your usersettings.json file. the first is terminal.integrated.shell.linux and the second is terminal.integrated.shellArgs.linux.

The plan is to have the shell command run ‘flatpak-spawn’ inside of the vscode container and to user the shell args to have open your toolbox.

One quick way to access this file is to - from within vscode - hit Ctrl + Shift + P and search for Preferences: Open Settings (JSON).

Here is an example of what you change it to.

{
    "terminal.integrated.shell.linux": "flatpak-spawn",
    "terminal.integrated.shellArgs.linux": [
        "--host",
        "toolbox",
        "enter"
    ]
}

This will make your default terminal your default toolbox. Which is pretty convenient if you ask me.

Potential Issues

Well, what if you are a more organized developer than I am, and you have multiple tool boxes and need to switch between them depending on the project? The answer I have for you is to just leave the default terminal as is and instead run flatpak-spawn --host toolbox enter --container <name> where <name> is the name of your container.

Specific plugins might not work well within the flatpak container. This is something outside the scope of this blog post. I don’t have an answer for that.

Conclusion

I think that adding a permission to the flatpak to run this command (which breaks containment) is a good compromise for a development tool like vscode. When I first found out you could do this, I had a mini heart attack because I didn’t know it was a permission and thought that any app could break containment. The fact that it is a permission is why I say it’s a good compromise.

To use the flatpak version of vscode on other distributions that don’t have toolbox, this is also possible. In theory you can change the shellArgs from ["--host", "toolbox", "enter"] to ["--host", "bash"]. Or any other combination of things which you might want or need.

Updated Conclusion (a few hours later)

It’s probably smarter to develop inside of containers. Microsoft has developed an extension for developing, specifically, inside of docker container. There is a github repository for this extension.