-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix: develop: use SHELL from rc script #8043
Conversation
Tested and seems to work perfectly for
I'm not sure what's going on with |
I see I had forgotten about this PR.
Looking at this again I see that it might indeed be safer to keep the @edolstra @fricklerhandwerk could this be looked at during the next Nix team meeting? |
I think that's a reasonable fix. In the big picture I'd like us to see it as a stopgap though, and nudge derivation authors, such as in Nixpkgs, to provide an executable that invokes a shell. Then we can do |
Triaged in Nix team meeting:
|
Won't this cause |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-11-10-nix-team-meeting-minutes-102/35379/1 |
I think I see now what you mean by non-interactive bash. Though I still don't understand how passing through
Since I didn't see tests regarding |
b7a6d1c
to
0a5ff22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried it out again, and it seems to still work like before 👍
One thing I did notice is that this can create an opposite problem for everyone using nix develop -c zsh
:
$ nix develop -c zsh
$ echo $SHELL
/nix/store/q0l990ga8fly926kc4sw5svjf12zfscf-bash-5.2-p15/bin/bash
I'm not sure if this is a huge issue, but it doesn't seem to affect my setup in any way. Additionally, using direnv fixes this quite nicely.
SHELL was inherited from the system environment. This resulted in a new shell being started, but with SHELL still referring to the system shell and not the one used by nix-develop. Applications like make, use SHELL to run commands, which meant that top-level commands are run inside the nix-develop-shell, but sub-commands are ran inside the system shell. This setenv forces SHELL to always be set to the shell used by nix-develop.
0a5ff22
to
ceab20d
Compare
Thanks!
Hmm, I think this is still correct behavior. The main case I ran into is where |
Hm, I don't really understand why the tests are failing inside CI. I tried it out on macOS and Linux inside |
I can comment out that check, as it isn't directly related to this PR. It was merely to check which shell is executed by |
Yeah I think that would be ok. It would be nice to add this test again later to avoid a regression there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this now. LGTM!
Awesome, thanks! 👍 |
nix: develop: use SHELL from rc script (cherry picked from commit 0d55d66) Change-Id: I83be6c63b282d7f01a0defa78d9e787c77f1f02d
But isn't the running shell zsh, and so $SHELL should point to it? |
There are other methods, see this SO answer. It also explains the caveat with using |
Motivation
Currently the SHELL environment variable is ignored in nix-develop. This means the variable is inherited from the user's shell.
This goes wrong when the SHELL variable refers to a different kind of shell like fish. Bash is started, while SHELL still refers to a fish shell. Configure scripts will fail in some cases.
I do have to say that I'm unsure about
SHELLOPTS
, but since the SHELL variable is changing I presumeSHELLOPTS
might be invalid for a different shell.I contemplated about
BASHOPTS
and thought it was related to the SHELL. Having BASHOPTS from a different SHELL seemed error-prone. So it seemed sensible to also inheritBASHOPTS
.Context
Resolves #7971
Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.