I am running Arch Linux on the Steam Deck. Steam Deck has a read only root file system which forces you to use Flatpak, or else to make the file system writable at the expense of wiping out, say, pacman-based installations every time they update the Deck's software.
I'm not a fan of Flatpak, I prefer Nix not least because it has packages that I need that are not available with Flatpak.
Nix allows you to run the entire package manager without root access from a chroot jail using nix-user-chroot utility.
Once installed, the command for getting into the chrooted nix environment is nix-user-chroot ~/.nix bash -l
which works fine in a new shell:
However if I stick that exact same line at the end of my .bashrc
I get a panic:
This appears to be exactly the same error that occurs if I run the command twice:
Keep in mind that the Steam Deck's shell already appears to be running in a chroot jail, as per this technique for finding out if I'm already chrooted (run without the nix-user-chroot ~/.nix bash -l
in my bashrc):
So my question is, how do I automatically run nix-user-chroot ~/.nix bash -l
so that it is invoked for every terminal?
SOME_FLAG_VARIABLE=1 nix-user-chroot ~/.nix bash -l
, is theSOME_FLAG_VARIABLE
environment variable available in the chroot shell? (It should be, but thisnix-user-chroot
command might clean the environment.) If it is, you can just check for that variable before executing the command in your bashrc:if [[ -z SOME_FLAG_VARIABLE ]]; then exec SOME_FLAG_VARIABLE=1 nix-user-chroot ~/.nix bash -l; fi