Skip to main content
2 of 4
edited title
Thomas Browne
  • 353
  • 1
  • 5
  • 16

Automatically execute `nix-user-chroot` when I start a terminal session (Steam Deck)

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:

enter image description here

However if I stick that exact same line at the end of my .bashrc I get a panic:

enter image description here

This appears to be exactly the same error that occurs if I run the command twice:

enter image description here

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):

enter image description here

So my question is, how do I automatically run nix-user-chroot ~/.nix bash -l so that it is invoked for every terminal?

Thomas Browne
  • 353
  • 1
  • 5
  • 16