This is a generic *nix related question. Is there some reason chsh queries /etc/shells before deciding whether it should change the shell entry in /etc/passwd? In nixos, setting programs.<shell>.enable sets up some startup files in /etc as well, but I don’t think that’s the reason /etc/shells exists.
As @NobbZ said, this is used as a whitelist of what shells are allowed. I think in NixOS, this file is only relevant with users.mutableUsers = true .
It’s usually easiest to just use /etc as the configuration directory. Otherwise, changing anything in --enable-etcdir= ends up requiring a rebuild of Zsh. Having a package depend directly on its configuration is usually considered bad practice in Nixpkgs. We let NixOS manage /etc for us, and this tends to work pretty good.
That is not entirely true. The file lists valid login shells. Some software uses the file to check if a user is a normal user since those will have valid login shell set in /etc/passwd. When improperly set up, it can cause issues like Normal users not appearing in login manager lists - #2 by aloysius