#nix #nixos #nix-shell #fish

app nix-your-shell

A nix and nix-shell wrapper for shells other than bash

6 stable releases

1.2.0 Apr 21, 2023
1.1.1 Feb 21, 2023
1.1.0 Feb 16, 2023
1.0.2 Feb 13, 2023
1.0.1 Feb 10, 2023

#139 in Command line utilities

26 downloads per month

MIT license

457 lines


nixpkgs Crates.io

A nix and nix-shell wrapper for shells other than bash.

nix develop and nix-shell use bash as the default shell, so nix-your-shell prints shell snippets you can source to use the shell you prefer inside of Nix shells.


nix-your-shell will print out shell environment code you can source to activate nix-your-shell.

Then, nix-shell, nix develop, and nix shell will use your shell instead of bash, unless overridden with a --command argument.


Add to your ~/.config/fish/config.fish:

if command -q nix-your-shell
  nix-your-shell fish | source


Add to your ~/.zshrc:

if command -v nix-your-shell > /dev/null; then
  nix-your-shell zsh | source /dev/stdin


You can either install nix-your-shell from this repository or from nixpkgs. The version packaged in nixpkgs will probably lag behind this repository by about a week or so.

nix profile

To install the latest version with nix profile, use one of:

nix profile install github:MercuryTechnologies/nix-your-shell
nix profile install "nixpkgs#nix-your-shell"


To install the latest version with nix-env, use one of:

nix-env --install --file https://github.com/MercuryTechnologies/nix-your-shell/archive/refs/heads/main.tar.gz
nix-env --install nix-your-shell

You can later remove the installed program with nix-env --uninstall nix-your-shell.

nix run

Run dynamically with nix run:

nix run github:MercuryTechnologies/nix-your-shell -- zsh
nix run "nixpkgs#nix-your-shell" -- zsh

Note that because the generated shell code will refer to the dynamically-built nix-your-shell executable, it may get garbage collected and cause problems later.


nix-your-shell is packaged in nixpkgs, so you can add pkgs.nix-your-shell to environment.systemPackages if you don't need the bleeding edge releases from this repo.

Add to a NixOS flake configuration using the overlay:


  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    nix-your-shell = {
      url = "github:MercuryTechnologies/nix-your-shell";
      inputs.nixpkgs.follows = "nixpkgs";

  outputs = {
  } @ attrs: {
    nixosConfigurations = {
      YOUR_HOSTNAME = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        specialArgs = attrs;
        modules = [./YOUR_HOSTNAME.nix];


}: {
  nixpkgs.overlays = [

  environment.systemPackages = [

  # Example configuration for `fish`:
  programs.fish = {
    enable = true;
    promptInit = ''
      nix-your-shell fish | source

  # ... extra configuration

Adding support for new shells

See #23 for an example of adding support for a new shell to nix-your-shell.

Comparison with any-nix-shell

any-nix-shell does roughly the same thing, and serves as the inspiration for nix-your-shell.

There are a few reasons I wrote nix-your-shell as a competitor:

  • any-nix-shell doesn't support Nix flakes through nix develop. nix-your-shell does.
  • any-nix-shell is a hodgepodge of shell scripts with multiple layers of eval and templating, making hacking or modifying it challenging. In contrast, nix-your-shell is written in Rust with a relatively straightforward structure (the shell environment code generation command and the nix wrappers are the same, so there's no need for dotfile executables on your $PATH).

However, any-nix-shell can optionally display the packages in the current shell on a righthand prompt. nix-your-shell does not support this.


~208K SLoC