zsh in nix-shell
In theory all you need to do to use
nix-shell is to set
zsh. Unfortunatly nix assumes that the
NIX_BUILD_SHELL is a bash variant and passes bash specific arguments to the shell. To fix this we need a shim that translates these arguments.
The information that
nix-shell exposes to the environment is also pretty sparse. It would be nice to know what derivations are included in the current environment for example to display them in the shells prompt.
git clone email@example.com:chisui/zsh-nix-shell.git $ZSH_CUSTOM/plugins/nix-shell
nix-shell to the plugins list in
Clone this repository and add the following to your
It should be possible to install this plugin through most
zsh plugin managers. If the one of your choice is not supported feel free to open an issue or even better create a pull request.
On MacOS you have to have an
bash with version
4 or greater. See Issue 14
nix-shell as you did before.
Commands run with
--command argument are executed in
nix-shells default shell. In the case of
--command you are put into a
zsh shell afterwords.
If you use the
--pure flag the interactive shell will be the default shell.
If you are inside a
IN_NIX_SHELL will be set. The value will be
pure if you specified
packages argument is passed through as
NIX_SHELL_PACKAGES to the shell.
If this Variable is empty
nix-shell was called for a specific nix expression which is stored in the
name environment variable.
These variables can now be used inside a theme to customize the prompt. Take a look at this variant of the agnoster theme for an example of how this might look.
Shell hooks are supported in general. Since they are executed inside of
bash before the
zsh shell is spawned they aren't executed in the same environment. This means that things like aliases wont work.
Please do. Pull requests welcome.