-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support custom shell in nix-shell/nix run #2681
Support custom shell in nix-shell/nix run #2681
Conversation
00c6f75
to
a96c777
Compare
I think this makes sense with |
a96c777
to
0f96d17
Compare
bash-only install scripts of course wouldn't run. However, why would you disallow using nix-shell with another shell, just because there use cases, where bash is needed? |
A nix-shell is mainly intended for reproducing builds interactively, setting that variable completely breaks that which is a bad user experience IMHO. There are already tools, like direnv, that handle the usecase you are looking for. |
0f96d17
to
19d1ef5
Compare
direnv looks appropriate for the job. Since that's the common oppinion here, I'm no going to remove the |
19d1ef5
to
b552da9
Compare
* Use `$NIX_RUN_INTERACTIVE_SHELL` (if present) as interactive shell for `nix run` If `--command` or `-c` are given, then bash is still used. One could also consider those environment variables to be arbitrary default commands that are executed when `nix run` is ran interactively and without a command. However, I think the most common use case (by far) is to set them to a shell, hence the name `[...]_INTERACTIVE_SHELL`. Previous work: Issue NixOS#419 (nix-shell ignoring SHELL enviroment variable) proposed to use `$SHELL` as interactive shell for `nix-shell`. This is of course not desirable for `nix-shell` since it's mainly inteded for reproducing builds with bash build scripts. For `nix run` such a feature seems however appropriate.
b552da9
to
a14527a
Compare
Given that, to my understanding, |
Certainly, but there's some possibility that it would break scripts that somehow use |
Because of Github's inaccurate search it's impossible to verify this without automating it but every single use of nix run in a script in a cursory glance is with |
Requesting this to be closed, seems to have been made obsolete by #3477. |
EDIT: Any changes to
nix-shell
have been removed from the PR. Onlynix run
is now affected.Use$NIX_SHELL_INTERACTIVE_SHELL
(if present) as interactive shell fornix-shell
$NIX_RUN_INTERACTIVE_SHELL
(if present) as interactive shell fornix run
If
,--run
--command
or-c
are given, then bash is still used.One could also consider those environment variables to be arbitrary default commands that are executed when
/nix-shell
nix run
are ran interactive and without a command. However, I think the most common use case (by far) is to set them to a shell, hence the name[...]_INTERACTIVE_SHELL
.Tests:I was unsuccessful adding tests to tests/nix-shell.sh. Any non-interactive test doesn't trigger the feature since it's only triggered in interactive shells.Previous work:
Issue #419 (nix-shell ignoring SHELL enviroment variable) proposed to use
$SHELL
as interactive shell fornix-shell
. This is of course not desirable if people depend onnix-shell
always using bash.With this change however, the feature is optional since it uses previously unused environment variables.