Fedora Silverblue Toolbox 101
Table of Contents
I’m a total fan of immutable Operating System. the peace of mind, stability, and consistency they provide is invaluable but getting started can be a bit difficult, specially if you’re coming for more traditional operating systems (mutable ones).
With this post I aim to show my current workflow working on Fedora Silverblue, I am by no means an expert on Fedora SilverBlue. I want to share the way I use these systems and I hope to helps other by sharing my current understanding and workflows.
I intend to update this post with new workflows and ideas that helped me to create this new mental map for stateless operating systems. I wish you find this useful.
How to install VSCode#
As a developer I find VSCode quite useful for a myriad of programming task, so a natural question arise: How do we install it on Fedora Silverblue?
Normally we would add the official Microsoft repository and install it using dnf
but in Silverblue we don’t have access to dnf
, instead we have rpm-ostree
. rpm-ostree
is a tool used to layer other software on top of your current Fedora image. But I find this not ideal since we will start to pollute our host OS, a better alternative is using Toolboxes.
toolbox
is a tool used to create separated mutable containers where we can install our tools, normally used to install CLI software is also a great alternative to install our IDE.
The magic of toolbox
is that it creates a separate mutable environment for us to install and use software that was not installed by default in our stateless operating system. This also apply to the repositories added to the system, each toolbox contains a separate list of repositories, independent of each other, even from the host.
Bear in mind these containers are not completely isolated from the host, as a consequence you cannot install mindlessly any unknown software thinking it’s isolated and safe to run. Please be cautious and treat the security inside these containers the same as you would with you local host system.
These toolboxes won’t pollute our main operating system and once we delete them, all the installed apps will be gone and our system will remain clean and stable. There is one catch, containers have by default access to our $HOME
directory, so if the program creates configurations or files in this directory they will remain after the deletion of the container (you can delete these files if needed).
After this introduction let’s start with the installation of VSCode inside a toolbox.
Creating the toolbox#
Let’s start by creating a new toolbox container, open a new terminal on the host OS and type the following:
To create the toolbox we enter:
You can give any name to your toolbox by replacing
programming-box
.
toolbox create programming-box
To enter the toolbox we type:
toolbox enter programming-box
The terminal prompt will add a small hexagon, this tell us we’re inside the toolbox.
Installing VSCode inside the toolbox#
Now that we are inside the toolbox we can use is as a regular mutable OS, inside the toolbox we have access to dnf
. This mean that the installation steps are the same as the official guide from Microsoft.
Inside the toolbox run the following commands to add the official repository and install the software.
Add the official repository by running this inside the toolbox.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
Update the repository list to get the newest software available.
dnf check-update
Install VSCode inside the toolbox.
sudo dnf install code # or code-insiders
Running VSCode#
You may noticed that after installing the software you cannot find it in the installed apps, this is due to the nature of the isolated containers. The app is only accessible from inside the toolbox, so a system wide access is not possible.
If you want a system-wide access to the software, you could consider using a community-driven Flatpak or layering the app using rpm-ostree
. I would not recommend layering unless is strictly necessary for your use case, and using a Flatpak may impose some extra steps to access the tools inside your toolboxes. Installing via dnf inside a toolbox seems like the best solution for most cases.
Flatpaks are the recommended way to install GUI apps in Fedora Silverblue but sometimes this way of working may create conflicts with other tools. For programming I find having everything I need (from toolchains to IDEs) inside a toolbox a hassle free solution.
To run VSCode, enter the toolbox container where the app is installed and run the following.
code
This will open the VSCode GUI and you can use it as usual.
You can install your programming toolchains inside the toolbox that contains VSCode and start using VSCode with these tools.
Considerations#
You can follow this steps to install any tool you need. For example, GitHub CLI tools are not included by default in Fedora repositories, so we can add the repository and install the software in a similar fashion as we did with VSCode.
Other CLI tools that are part of Fedora repositories can be installed easily inside a toolbox by using sudo dnf install app_name
.
Conclusion#
Immutable Operating Systems are a great way to get rock solid and performant systems without worrying about updates or dependency problems. They container workflow is a great way to separate your tools and projects.
By using toolboxes you can add and configure your toolchains and programs as you would in a Mutable OS, with the adding benefit that once you’re done you can delete the changes and your system will stay clean and secure.
I wish these small how’s to helps you in your journey towards immutability.