配置nix-shell使用Bash以外的shell?

jos*_*iah 6 shell configuration development-environment nixos

我在NixOS 15和nix-shell v1.10上.我现在使用Zsh作为我的主shell,并且当我在由Nix表达式构建的开发环境中工作时,想在nix-shell中与Oh-My-Zsh一起使用它.

如果它有帮助,这是我为Rails项目设置的Nix环境之一:

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
    ];
  };
}
Run Code Online (Sandbox Code Playgroud)

**编辑**

以这种方式运行命令并不表示在CLI提示符中我在nix-shell中.有没有一种简单的方法可以检测到这一点,以便我可以在我的脚本中快速编写脚本zshrc

jos*_*iah 6

感谢#nixos IRC 频道上的人让我快速回答。

这样做的命令是:

nix-shell . --command "zsh"

  • 如果有人有更好的答案,我将不接受这一点。也许有一种方法可以做到这一点,可以更多地替换实际运行的基本 shell nix-shell ?我认为使用 `--command` 仅在创建 shell 时从原始 Bash shell 执行 Zsh。 (2认同)

小智 5

最近发布的PR #545将解决这个问题