The steam deck, in terms of partition layout, is much closer to a modern phone than to a conventional PC.
The partition are divided in a AB layout, where you have a identical copy of critical files between partitions A and B of multiple partitions. This means that is much more secure and stable to update but it also means that your changes are easly reverted and of course those partitions are readonly and really low in extra space as it does not need much more.
So how can it, being imutable and always reseting, have personalized packages installed permanently?
Well for that we have 2 answers containers with complete systems where we can use its tools or using a rootless package system, I will go with the latter and the former could be for other stuff.
Nix is a package manager for an OS called NixOS where packages are installed with independecy of eachothers, having also the ability of having different versions of the same packages.
So saying all that whats the importance of this package manager for the deck when the deck uses the pacman package manager and is arch? Well the reason is because it is also rootless! And for being the packages really well isolates it lets us install Nix in any Unix OS neat right so how can we install it in the deck?
Well nix is kinda all that sweet honey but it does have a problem, it does not have bit problem, it does not you put the /nix folder wherenever you want, you can use nix-portable which is a wrapper for using a container and does not let us use the more interesting stuff of nix like nix-env and having the env in our normal shell transparently and if you try to link the folder to another it spits out errors, so what we can do?
Well for that we can mount it to our sdcard or home directory :D.
First of create a nix folder or where you want it to be, for exemple I put mine in my sdcard being its path /run/media/mmcblk0p1/nix/, lets call the path for your folder and mine as $NIX.
Now lets start with the installation.
- Unlock the filesystem with:
sudo steamos-readonly disable
- creat the /nix folder
sudo mkdir /nix && sudo chown deck /nix
- Bind the /nix folder with the folder you created
sudo mount --bind $NIX /nix
- Installing nix as single user:
sh <(curl -L https://nixos.org/nix/install) --no-daemon
- Added it in your bashrc if it is not already there:
echo "source /home/deck/.nix-profile/etc/profile.d/nix.sh" >> ~/.bashrc
And we are done.
To install packages you just need to use nix-env -i <package-name>
.
To search you can do it in here.
After rebooting the /nix file will be unbinded, to fix this you can download the bind_nix.service and put it in /etc/systemd/system and download the bind_nix.sh and put it in /home/deck/.local/bin/bind_nix.sh, after that enable it.
In resume:
sudo curl https://gist.githubusercontent.com/OnikenX/00885157e29222b148778d078c93b0af/raw/02dae1fd749bd4090ddaba52e99123ffceae9da3/bind-nix.service -o /etc/systemd/system/bind-nix.service
sudo systemctl enable --now bind_nix.service
Always remember that the deck can delete bind_nix.service when updating so you could need to restore it.