Appearance
Why & How To Use Flatpak Extensions ​
Flatpak extensions come in handy when ... well, when you want to extend the feature set of a Flatpak with a certain SDK.
I came across the issue recently why trying to install Rust in my VSCode Flatpak.
Installing A Flatpak Extension. ​
This is the easy part, to download an extension, lets say Rust because thats the extension I wanted to isntall, you just type
shell
$ flatpak search rust
## Example Output:
#Name Beschreibung Application ID Version Zweig Remotes
#SongRec An open-source, unofficial Shazam client for Linux, written … ….github.marinm.songrec 0.3.2 stable flathub
#Geopard A gemini browser com.ranfdev.Geopard 1.1.0 stable flathub
#Youp for whatsa… Whatsapp com.gigitux.youp 2.0 stable flathub
#Rust stable Rust stable compiler and tools extension for the flatpak Fre… ….Extension.rust-stable 1.61.0 21.08 flathub
#Rust stable Rust stable compiler and tools extension for the flatpak Fre… ….Extension.rust-stable 1.55.0 20.08 flathub
#Rust stable Sdk… Rust stable compiler and tools ….Extension.rust-stable 1.47.0 19.08 flathub
#Rust nightly Sd… Rust nightly compiler and tools …Extension.rust-nightly 1.63.0-nightly-20220528 21.08 flathub
#Rust nightly Sd… Rust nightly compiler and tools …Extension.rust-nightly 1.60.0-nightly-20220115 20.08 flathub
#Rust nightly Sd… Rust nightly compiler and tools …Extension.rust-nightly 19.08 flathub
#Freedesktop SDK Tools and headers for developing applications org.freedesktop.Sdk 21.08.13 21.08 flathub
#Freedesktop SDK Tools and headers for developing applications org.freedesktop.Sdk 20.08.19 20.08 flathub
#Stpa-documentat… A System Theoretic Process Analysis tool - that facilitates … ….stpadocumentationtool 1.0 stable flathubThe extension I wanted was rust-stable so I installed it via:
shell
$ flatpak install flathub org.freedesktop.Sdk.Extension.rust-stableExtensions usually start with org.freedesktop.Sdk.Extension. so you only need to append the Application ID name of the Extension you like to install. Flatpak will likely also want to know which version, which you could answer using the newest looking version tag.
Now you have that extension installed, but it isn't enabled or used anywhere.
Using an Extension with a Flatpak ​
According to the note VSCode gave me upon first launch, you can start using an extension by starting the flatpak with a special command, in my case it looks like this:
shell
$ FLATPAK_ENABLE_SDK_EXT=rust-stable flatpak run com.visualstudio.codeNow this works great, I can just enter the rustc command in my VSCode terminal and use it however I like, but that works only so long as I start VSCode using this command. Using my Desktop Environment for that ain't gonna work. So how do you enable it permanently?
Enable An Extension Permanently ​
You can use flatpak override to modify settings for a local Flatpak.
Since using an Extension is done by setting an environment variable, we can use this knowledge to override the flatpak settings of VSCode (or any other Flatpak) to always use that environment variable, resulting in the Extension being always enabled.
The command is just sudo flatpak override --env=FLATPAK_ENABLE_SDK_EXT=<extension-id> <flatpak-id>, or in my case:
shell
$ sudo flatpak override --env=FLATPAK_ENABLE_SDK_EXT=rust-stable com.visualstudio.codeDone! Now you just need to start your Flatpak and the extension will be automatically enabled ^^