bash: --stdin : option non valable
Issue description
When I run the nix-shell -p XXX I get an error:
/run/current-system/sw/bin/bash: --stdin : option non valable
I installed the plugin according to the installation guide:
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.5.0";
sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91";
};
}
Steps to reproduce
❯ nix-shell -p peek
/run/current-system/sw/bin/bash: --stdin : option non valable
Utilisation : /run/current-system/sw/bin/bash [option longue GNU] [option] ...
/run/current-system/sw/bin/bash [option longue GNU] [option] fichier-script ...
Options longues GNU :
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--pretty-print
--rcfile
--restricted
--verbose
--version
Options du shell :
-ilrsD ou -c commande ou -O shopt_option (invocation seulement)
-abefhkmnptuvxBCHP ou -o option
My full installation file (home manager)
{ config, lib, pkgs, ... }:
let
# load the configuration that we was generated the first
# time zsh were loaded with powerlevel enabled.
# Make sure to comment this part if you want to run
# again 'p10k configure' and to copy the generated file
# $ mv ~/.p10k.zsh p10k-config/p10k.zsh
configThemeNormal = ./p10k-config/p10k.zsh;
configThemeTTY = ./p10k-config/p10k_tty.zsh;
in
{
fonts.fontconfig.enable = true;
home.packages = with pkgs; [
# Meslo Nerd Font patched for Powerlevel10k
# Restart Konsole and configure it (profile) to choose MesloLGS NF
meslo-lgs-nf
# For fuzzy filter in cd
# https://github.com/junegunn/fzf
fzf
];
programs.zsh = {
enable = true;
# enableAutosuggestions = true;
enableCompletion = true;
enableSyntaxHighlighting = true;
enableVteIntegration = true;
defaultKeymap = "emacs";
initExtra = ''
# By default backward deleting a word would consider / as a regular
# word. Now this problem is gone with this option, see also
# https://stackoverflow.com/questions/444951/zsh-stop-backward-kill-word-on-directory-delimiter
autoload -U select-word-style
select-word-style bash
# Ctrl-arrows fail in konsole
# https://unix.stackexchange.com/questions/58870/ctrl-left-right-arrow-keys-issue
# urxvt/rxvt-unicode (and maybe others):
bindkey "^[Od" backward-word
bindkey "^[Oc" forward-word
# alacritty, konsole, terminator, xterm (and maybe others):
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word
# to find the proper char just type cat and type your char!
bindkey "^[[3~" delete-char
# By default, only alt-backspace deletes a word, now we can also use
# ctrl instead of Alt
bindkey "^H" backward-kill-word
# The powerlevel theme I'm using is distgusting in TTY, let's default
# to something else
# See https://github.com/romkatv/powerlevel10k/issues/325
# Instead of sourcing this file you could also add another plugin as
# this, and it will automatically load the file for us
# (but this way it is not possible to conditionally load a file)
# {
# name = "powerlevel10k-config";
# src = lib.cleanSource ./p10k-config;
# file = "p10k.zsh";
# }
if zmodload zsh/terminfo && (( terminfo[colors] >= 256 )); then
[[ ! -f ${configThemeNormal} ]] || source ${configThemeNormal}
else
[[ ! -f ${configThemeTTY} ]] || source ${configThemeTTY}
fi
'';
## https://github.com/marlonrichert/zsh-autocomplete
##
completionInit = let
autoComplete = pkgs.fetchFromGitHub {
owner = "marlonrichert";
repo = "zsh-autocomplete";
rev = "4c363ff553be227db90842d7481fd6e02de8703c";
sha256 = "sha256-3hRRrTpRtVrQdc2rTO67Sn1SJ5nPop9liTJfu3qRYHs=";
};
in ''
source ${autoComplete}/zsh-autocomplete.plugin.zsh
'';
plugins = [
{
# A prompt will appear the first time to configure it properly
# make sure to select MesloLGS NF as the font in Konsole
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.5.0";
sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91";
};
}
];
};
}
Technical details
- system:
"x86_64-linux" - host os:
Linux 5.15.34, NixOS, 22.05 (Quokka), 22.05pre-git - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.8.0pre20220411_f7276bc - channels(leo):
"home-manager, local-nixos-unstable, local-nixpkgs-unstable, nixgl, nixos-20-03-20.03, nixos-unstable, test" - channels(root):
"nixos" - nixpkgs:
/nix/var/nix/profiles/per-user/root/channels/nixos
zsh 5.9 (x86_64-pc-linux-gnu)
This plugin determines the current zsh executable by evaluating $SHELL it seems that this variable points to bash. Either change your login shell to zsh or override SHELL in your .zshrc. I'll add this constraint to the readme.
Does this fix your issue?
Oh interesting, I'll try. Shouldn't the zsh plugin automatically ensure that $SHELL is properly configured?
Also, I have two questions:
- do you plan to support developing in zsh like calling the
installPhasefrom the shell? - do you know how this project compares to https://github.com/haslersn/any-nix-shell
Hello,
I had the same issue and I can confirm that adding SHELL=zsh in my .zshrc seems to have fixed the issue.
After setting SHELL=zsh, ssh -oProxyCommand no longer works:
$ SHELL=zsh ssh -oProxyCommand=false foo
zsh: No such file or directory
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
So that's not a generic solution for NixOS.
I think that we should just use
NIX_EXECUTING_SHELL=$(readlink /proc/$$/exe) to detect the currently running shell.
@clefru I incorporated your suggestion and created a new release v0.6.0.