nix-community / nix-on-droid

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

~/.bash_profile not being loaded on startup #71

Closed zanculmarktum closed 2 years ago

zanculmarktum commented 4 years ago

I know I could use .bashrc, but why isn't .bash_profile being loaded?

The original Termux loaded the .bash_profile by the way.

How was bash invoked in this version?

t184256 commented 4 years ago

It's at the end of /data/data/com.termux.nix/files/usr/usr/lib/login-inner, and yes, it's not invoked as a login shell. Should it be?

zanculmarktum commented 4 years ago

Should it be?

Yeah, I guess since termux is supposed to be tty login screen IMO.

Anyway if you're not going to fix it, can you tell me how to make bash being invoked as login shell?

Passing -l maybe?

t184256 commented 4 years ago

I have no opinion on fixing it yet.

Yeah, you can try -l. Will it prevent it from reading bashrc?

zanculmarktum commented 4 years ago

Can I make it permanent to /usr/lib/login-inner?

Also I've noticed that it doesn't source /path/to/nix/profile/etc/bash_completion.d/* either, probably because of the missing /etc/bashrc (which sources it) which NixOS has it. But I think, this is Nix issue, since Nix (not NixOS) doesn't seem to have it.

t184256 commented 4 years ago

You can fork this repository, change it in your fork and set the channel to point to your repository instead. Or just use a local checkout. Lots of other ways, probably.

Losing bashrc support and sensible defaults doesn't sound that great. What would be other benefits of switching to a login shell?

Not sure not shipping /etc/bashrc a Nix issue. Nix just provides bash.

Gerschtli commented 4 years ago

What about introducing a new option called something like user.shellArgs? You could add -l in this array and use it in login-inner.

For the bash_completion issue you could create a new module that creates a /etc/bashrc with the necessary content.

zanculmarktum commented 4 years ago

What would be other benefits of switching to a login shell?

Well, I have .bash_profile sourcing .bashrc so I get the same environment either I run shell from tty or terminal.

Not sure not shipping /etc/bashrc a Nix issue. Nix just provides bash.

Right, but isn't nix-on-droid supposed to be NixOS, not just Nix? It even has similar functionality to nixos-rebuild.

t184256 commented 4 years ago

Yeah, modules and options solve everything, but one-size-fits-all defaults are always better.

Gerschtli commented 4 years ago

I think it would be better to start a login shell as this is this is the first process started in the nix-on-droid environment. And as termux uses a login shell, we should maybe stream-line it because this is probably the correct usage.

But I think it would be straight forward to add a module for writing /etc/bashrc.

Gerschtli commented 2 years ago

This should be fixed by via https://github.com/t184256/nix-on-droid/pull/139. Please reopen if this is still an issue.