Introduction
In my previous post I talked about how to use systemd-sysext
to add software to the Steam Deck without modifying the root filesystem. In this post I will give a brief overview of two additional methods.
Distrobox
distrobox is a tool that uses containers to create a mutable environment on top of your OS.
With distrobox you can open a terminal with your favorite Linux distro inside, with full access to the package manager and the ability to install additional software. Containers created by distrobox are integrated with the system so apps running inside have normal access to the user’s home directory and the Wayland/X11 session.
Since these containers are not stored in the root filesystem they can survive an OS update and continue to work fine. For this reason they are particularly suited to systems with an immutable root filesystem such as Silverblue, Endless OS or SteamOS.
Starting from SteamOS 3.5 the system comes with distrobox (and podman) preinstalled and it can be used right out of the box without having to do any previous setup.
For example, in order to create a Debian bookworm container simply open a terminal and run this:
$ distrobox create -i debian:bookworm debbox
Here debian:bookworm
is the image that this container is created from (debian
is the name and bookworm
is the tag, see the list of supported tags here) and debbox
is the name that is given to this new container.
Once the container is created you can enter it:
$ distrobox enter debbox
Or from the ‘Debian’ entry in the desktop menu -> Lost & Found.
Once inside the container you can run your Debian commands normally:
$ sudo apt update
$ sudo apt install vim-gtk3
Nix
Nix is a package manager for Linux and other Unix-like systems. It has the property that it can be installed alongside the official package manager of any distribution, allowing the user to add software without affecting the rest of the system.
Nix installs everything under the /nix
directory, and packages are made available to the user through a new entry in the PATH
and a ~/.nix-profile
symlink stored in the home directory.
Nix is more things, including the basis of the NixOS operating system. Explaning Nix in more detail is beyond the scope of this blog post, but for SteamOS users these are perhaps its most interesting properties:
- Nix is self-contained: all packages and their dependencies are installed under
/nix
. - Unlike software installed with
pacman
, Nix survives OS updates. - Unlike
podman
/distrobox
, Nix does not create any containers. All packages have normal access to the rest of the system, just like native SteamOS packages. - Nix has a very large collection of packages, here is a search engine: https://search.nixos.org/packages
The only thing that Nix needs from SteamOS is help to set up the /nix
directory so its contents are not stored in the root filesystem. This is already happening starting from SteamOS 3.5 so you can install Nix right away in single-user mode:
$ sudo chown deck:deck /nix
$ wget https://nixos.org/nix/install
$ sh ./install --no-daemon
This installs Nix and adds a line to ~/.bash_profile
to set up the necessary environment variables. After that you can log in again and start using it. Here’s a very simple example (refer to the official documentation for more details):
# Install and run Midnight Commander
$ nix-env -iA nixpkgs.mc
$ mc
# List installed packages
$ nix-env -q
mc-4.8.31
nix-2.21.1
# Uninstall Midnight Commander
$ nix-env -e mc-4.8.31
What we have seen so far is how to install Nix in single-user mode, which is the simplest one and probably good enough for a single-user machine like the Steam Deck. The Nix project however recommends a multi-user installation, see here for the reasons.
Unfortunately the official multi-user installer does not work out of the box on the Steam Deck yet, but if you want to go the multi-user way you can use the Determinate Systems installer: https://github.com/DeterminateSystems/nix-installer
Conclusion
Distrobox and Nix are useful tools and they give SteamOS users the ability to add additional software to the system without having to modify the base operating system.
While for graphical applications the recommended way to install third-party software is still Flatpak, Distrobox and Nix give the user additional flexibility and are particularly useful for installing command-line utilities and other system tools.
Hello, I installed nix in multi-user installation on SteamOS 3.5. After update to SteamOS 3.6 nix-env -q not working (other apps too). I thought that problem is in multi-user installation (I don’t know the difference, I have only one user: deck@steamdeck) so tied to install in single-user as you showed, but I had some error. Should I install multi-user way or remove nix (how?) and install again single-user (will I lose my apps and settings for them?)?
What installer did you use?
With the DeterminateSystems installer you should be able to upgrade from 3.5 to 3.6 and have everything working.
https://github.com/DeterminateSystems/nix-installer
I would need to see the exact error messages and the status of the systemd units (in particular: systemctl status nix-daemon.socket) in order to know more.
Also: were you running any SteamOS beta or did you upgrade from 3.5 stable to 3.6 stable?
If you want, feel free to open an issue at https://github.com/ValveSoftware/SteamOS/issues with the details and we can continue there.
Thank you for the answers.
I installed nix package on stable 3.5 on the Steam Deck using:
curl –proto ‘=https’ –tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
sh -s — install
[Q1] If I run this code once again will I lose everything since overwriting?
After update to stable 3.6 i tried to run your code since I have only one user and don’t think about creating the new ones (there is some Polish texts, because I have Polish system):
(deck@steamdeck ~)$ sudo chown deck:deck /nix
[sudo] hasło użytkownika deck:
(deck@steamdeck ~)$ wget https://nixos.org/nix/install
–2024-11-11 20:14:53– https://nixos.org/nix/install
Załadowano certyfikat CA ‘/etc/ssl/certs/ca-certificates.crt’
Translacja nixos.org (nixos.org)… 3.75.10.80, 3.125.36.175, 2a05:d014:58f:6201::65, …
Łączenie się z nixos.org (nixos.org)|3.75.10.80|:443… połączono.
Żądanie HTTP wysłano, oczekiwanie na odpowiedź… 302 Found
Lokalizacja: https://releases.nixos.org/nix/nix-2.25.0/install [podążanie]
–2024-11-11 20:14:54– https://releases.nixos.org/nix/nix-2.25.0/install
Translacja releases.nixos.org (releases.nixos.org)… 151.101.2.217, 151.101.66.217, 151.101.130.217, …
Łączenie się z releases.nixos.org (releases.nixos.org)|151.101.2.217|:443… połączono.
Żądanie HTTP wysłano, oczekiwanie na odpowiedź… 200 OK
Długość: 4267 (4,2K) [text/plain]
Zapis do: `install.1′
install.1 100%[====================================================================================================>] 4,17K –.-KB/s w 0s
2024-11-11 20:14:55 (27,2 MB/s) – zapisano `install.1′ [4267/4267]
(deck@steamdeck ~)$ sh ./install –no-daemon
downloading Nix 2.24.10 binary tarball for x86_64-linux from ‘https://releases.nixos.org/nix/nix-2.24.10/nix-2.24.10-x86_64-linux.tar.xz’ to ‘/tmp/nix-binary-tarball-unpack.lj6dpOSdg7’…
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.5M 100 22.5M 0 0 3233k 0 0:00:07 0:00:07 –:–:– 4109k
Note: a multi-user installation is possible. See https://nixos.org/manual/nix/stable/installation/installing-binary.html#multi-user-installation
performing a single-user installation of Nix…
copying Nix to /nix/store……………………………cp: nie można utworzyć katalogu ‘/nix/store/./hdy82qidsybc3fg561pqfwagv44vschb-nix-2.24.10.34472’: Brak dostępu
(deck@steamdeck ~)$ systemctl status nix-daemon.socket
Unit nix-daemon.socket could not be found.
Update also don’t work:
(deck@steamdeck ~)$ sudo -i nix upgrade-nix
-bash: linia 1: nix: nie znaleziono polecenia
Before I raise an issue I want to find answer for my question [Q1] and if so try to use that code when I will be 100% sure that I wouldn’t lose installed apps.
If multi-user installation won’t work or will overwrite installed apps then I will raise a ticket and mark you there so you could follow the thread.
Wait, don’t reinstall anything, I think I know what the problem is.
Try this:
sudo ln -s /nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.socket /etc/systemd/system/
And create the file /etc/profile.d/nix.sh (if it doesn’t exist yet) with the following contents:
if [ -e ‘/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh’ ]; then
. ‘/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh’
fi
Reboot the system and check if things work now.
Okay I run it.
(deck@steamdeck ~)$ systemctl status nix-daemon.socket
● nix-daemon.socket – Nix Daemon Socket
Loaded: loaded (/etc/systemd/system/nix-daemon.socket; enabled; preset: disabled)
Active: active (listening) since Tue 2024-11-12 22:41:46 CET; 35min ago
Triggers: ● nix-daemon.service
Listen: /nix/var/nix/daemon-socket/socket (Stream)
CGroup: /system.slice/nix-daemon.socket
lis 12 22:41:46 steamdeck systemd[1]: Listening on Nix Daemon Socket.
What should I do now? I’m new in linux world, could you explain what happened here, please?
(You can reach me via email if you don’t want to do a spam here)