I'm trying to setup zsh
on my nixos
machine.
I currently have
programs.zsh = {
enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
};
users.defaultUserShell = pkgs.zsh;
in my etc/nixos/configuration.nix
.
This has the effect of starting zsh
when I open a shell, as expected.
The unexpected thing is that zsh
is asking me for additional configuration
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).
I was expecting to be able to configure zsh
directly with configuration in configuration.nix
.
Is my expectation wrong? Should I necessarily have a .zshrc
? If so, how are the configuration in configuration.nix
and in .zshrc
merged?
Your configuration.nix
describes system-level configuration of packages. NixOS will use the options under programs.zsh.*
to derive a system-wide zsh config file under /etc/zshrc
.
On startup, zsh sources both /etc/zshrc
and ~/.zshrc
in that order (among other files). Since you don't have a ~/.zshrc
, it assumes that you haven't set up zsh for this user, and drops you into the new user installation process.
There is no conflict between system-level and user-level zshrc
s.
The easiest solution is just to put an empty zshrc in your home. (You could also specify the existence of this file declaratively in your nix config, or use home-manager for user level configuration.)