12

I'm on NixOS 15 and nix-shell v1.10. I use Zsh as my main shell now, and would like to use it in conjuction with Oh-My-Zsh within the nix-shell as well when I'm working in development environments built by a Nix expression.

If it helps, here is one of the Nix environments I have set up for a Rails project:

with import <nixpkgs> {}; {
  cannyFreeRadicalEnv = stdenv.mkDerivation rec {
    name = "canny-free-radical-env";
    version = "0.1";
    src = ./.;
    buildInputs = [
        stdenv
        ruby_2_2_2
        bundler_HEAD
        zlib
        postgresql94
        sqlite
    ];
  };
}

** Edit **

Running the command this way does not indicate in the CLI prompt that I'm in the nix-shell. Is there an easy way to detect this so that I can script it up quickly in my zshrc?

josiah
  • 1,314
  • 1
  • 13
  • 33

4 Answers4

6

Open a shell using:

nix-shell . --command "zsh"

Thanks to the guys on the #nixos IRC channel for getting me a quick answer.

Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
josiah
  • 1,314
  • 1
  • 13
  • 33
  • 2
    I'm leaving this unaccepted in case someone has a better answer. Maybe there is a way to do this that gets more to replacing the actual base shell nix-shell runs on? I think using `--command` only executes Zsh from the original Bash shell on shell creation. – josiah Oct 09 '15 at 15:41
  • As it's been a few days, I'm assuming I won't get a better answer at this point. – josiah Oct 13 '15 at 16:04
  • 1
    This works well as long as you don't need to call the shell functions nix-shell generate (`configurePhase` etc) – olejorgenb Dec 24 '16 at 04:53
  • Not enough information to help users of `zsh`. – Romeo Jan 28 '23 at 10:09
5

there is PR #545 opened recently which will address this

Rok Garbas
  • 86
  • 2
0

You might want to try this Zsh plugin.

https://github.com/chisui/zsh-nix-shell

Cyrus Yip
  • 479
  • 5
  • 9
0

any-nix-shell worked for me. There is also a more manual approach presented here https://ianthehenry.com/posts/how-to-learn-nix/nix-zshell/

Note however that these solutions are not forwarding alias and phases like unpackPhase.

tobiasBora
  • 1,542
  • 14
  • 23