nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.33k stars 74 forks source link

How to get recovered in a broken login shell? #402

Closed amalgame21 closed 2 months ago

amalgame21 commented 3 months ago

I put this in the nix-on-droid.nix

user.shell = pkgs.zsh;

and ran nix-on-droid switch --flake ~/.config/nix-on-droid/flake.nix and break the login shell. Now I know I should use

 user.shell = "${lib.getExe pkgs.zsh}";

instead. Now it throws errors when I open nix-on-droid then it automatically exit immediately. How can I recover it in this broken state? If not, how can I backup the ~/.config/nix-on-droid folder in this state? Thank you for your help!

t184256 commented 2 months ago

When setting a new shell, it's better to open new sessions to keep a working one running until you know you don't lock yourself out. Now, when you had locked yourself out, exit all sessions, long-press app icon, "Failsafe", execute /data/data/com.termux.nix/files/usr/bin/login bash, recover. More at #284.

amalgame21 commented 2 months ago

It works! Replacing the line with user.shell = "${lib.getExe pkgs.zsh}"; and run nix-on-droid switch result in error: creating directory '/data/local/tmp/nix-build-login-inner.drv-0': Permission denied error in the "Failsafe" shell. So I delete the line and nix-on-droid switch run successfully. I add back user.shell = "${lib.getExe pkgs.zsh}"; and run nix-on-droid switch later on in normal shell, it also run successfully. Thank you very much for your help!