Command Shell

From NixOS Wiki
Jump to: navigation, search

A shell is a program that translates text commands (like ls, vim, reboot etc) into instructions for your computer. The default shell on NixOS is bash, but it can be easily changed.

Note: Zsh is used here as an example. You can use other shells, e.g. fish or nushell.

Enable

When adding a new shell, always enable the shell system-wide, even if it's already enabled in your Home Manager configuration, otherwise it won't source the necessary files.

For example, for Zsh:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
programs.zsh.enable = true;


Changing the default shell

For all users

To set a command shell as the default for all users, use the defaultUserShell option.

For example, to set Zsh as the default user shell for all users:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
users.defaultUserShell = pkgs.zsh;


For a specific user

To set a command shell as the default for a particular user, use the <name>.shell option.

For example, to set user "myuser"'s shell to fish:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
users.users.myuser.shell = pkgs.fish;


You can also choose whether or not a user should use the default shell:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
users.users.myuser.useDefaultShell = true;


See also