chisui / zsh-nix-shell

zsh plugin that lets you use zsh in nix-shell shells.
BSD 3-Clause "New" or "Revised" License
373 stars 19 forks source link

Invoking nix-shell twice results in `bash: --stdin: invalid option` #28

Closed ZenithalHourlyRate closed 3 years ago

ZenithalHourlyRate commented 3 years ago

Issue description

Did you install the plugin according to the installation guide? If not, does the issue persist if you do install it that way?

According to the installtion guide.

Steps to reproduce

nix-shell -p <whatever>
# inside the nix-shell
nix-shell -p <whatever>

I set -x for these setups, the log is at https://shz.al/R9P6.

Technical details

Please run the following commands and paste the results:

  1. command nix-shell -p nix-info --run "nix-info -m"
  2. zsh --version
$ command nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.47, NixOS, 21.11pre304626.8ecc61c91a5 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.14`
 - channels(zenithal): `"nixpkgs"`
 - channels(root): `"nixos"`
 - channels(rvalue): `"nixpkgs"`
 - channels(gravifer): `""`
 - nixpkgs: `/home/zenithal/.nix-defexpr/channels/nixpkgs`

 # zenithal @ Sun in ~ [23:35:02]
$ zsh --version
zsh 5.8 (x86_64-pc-linux-gnu)

Discussion

Seems that https://github.com/chisui/zsh-nix-shell/blob/a2139b32fc1429160fc40658c9e16177c20597fc/nix-shell.plugin.zsh#L55 caused the problem as after one nix-shell, $SHELL is set to /home/zenithal/.oh-my-zsh/custom/plugins/nix-shell/scripts/buildShellShim

chisui commented 3 years ago

Does the issue persist if you try this branch? https://github.com/chisui/zsh-nix-shell/tree/issue/28

ZenithalHourlyRate commented 3 years ago

It works!

BTW, NIX_SHELL_PACKAGES should be concated so I suggest the following change (want a Co-authored-by)

-  local NIX_SHELL_PACKAGES=""
+  local LOCAL_NIX_SHELL_PACKAGES="${NIX_SHELL_PACKAGES}"

and change the variable name in the other places accordingly.

It works for me as follows (with modified zsh-theme)

# zenithal @ Sun in ~ [3:44:01]
$ nix-shell -p nodejs

# zenithal @ Sun in ~ [3:44:07]  { nodejs }
$ nix-shell -p go

# zenithal @ Sun in ~ [3:44:10]  { nodejs go }
$ nix-shell -p mtr

# zenithal @ Sun in ~ [3:44:18]  { nodejs go mtr }
$
chisui commented 3 years ago

Ok, I'll merge the change.


The feature request seems like a good idea. If you open a pull-request you'll be listed as a contributor.