Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure nix-shell to use a shell other than Bash?

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?

like image 726
josiah Avatar asked Oct 09 '15 04:10

josiah


People also ask

How do I leave nix shell?

Like --command , but executes the command in a non-interactive shell. This means (among other things) that if you hit Ctrl-C while the command is running, the shell exits.

How do I change my default NixOS shell?

Changing default shelldefaultUserShell = pkgs. zsh; then run nixos-rebuild switch and reboot your system.

What is default nix?

nix is used as default file when importing directory. So if you write x = import ./some/directory; , then ./some/directory/default.

What is nix environment?

A Nix environment keeps track of references automatically, which allows unused packages to be garbage collected when no other package depends on them. At the cost of greater storage requirements, all upgrades in Nix are guaranteed to be both atomic and capable of efficient roll-back.


2 Answers

Open a shell using:

nix-shell . --command "zsh"

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

like image 100
josiah Avatar answered Oct 29 '22 23:10

josiah


there is PR #545 opened recently which will address this

like image 41
Rok Garbas Avatar answered Oct 29 '22 23:10

Rok Garbas