[Nix-dev] some basic questions from a new NixOS user
Linus Arver
linusarver at gmail.com
Thu Dec 1 03:37:22 CET 2011
On Sat, Nov 26, 2011 at 02:42:03PM -0800, Linus Arver wrote:
> On Fri, Nov 25, 2011 at 12:35:01AM +0100, Nicolas Pierron wrote:
> > Hi Linus,
> >
> > On Thu, Nov 24, 2011 at 22:44, Linus Arver <linusarver at gmail.com> wrote:
> > > On Thu, Nov 24, 2011 at 07:00:29PM +0100, Nicolas Pierron wrote:
> > chsh does not work if you reference your user inside NixOS
> > configuration file, the reason is that each time you boot, NixOS
> > activation script will update /etc/passwd file with the list of users
> > and shells. But you can update your shell inside your
> > configuration.nix file. Have a look at one module of my
> > configurations:
> >
> > https://svn.nixos.org/repos/nix/configurations/trunk/misc/nicolas.b.pierron/common/user.nix
>
> Thanks for this. I adapted the
>
> users.extraUsers = [
> { name = "nicolas";
> uid = 1000;
> group = "users";
> extraGroups = [ "wheel" "share" ];
> description = "Nicolas Pierron";
> home = "/home/nicolas";
> shell = pkgs.zsh + "/bin/zsh";
> }
> ];
>
> users.extraGroups = [
> { name = "share";
> gid = 1001;
> }
> ];
>
> environment.systemPackages = [
> pkgs.zsh
> ];
I just wanted to point out to future zsh users for NixOS that using the
above setting will work if you are inside an X process, because the bash
shell that runs the X stuff sources /etc/bashrc, /etc/profile for all
the right global system PATHs (see
/etc/nixos/nixos/modules/programs/bash/bash.nix). But if you log in from
a virtual console tty (e.g., CTRL+ALT+F1), or if you SSH in, your zsh
won't source the abovementioned files, resulting in an unusable shell.
To get around this, you can instead just use "/bin/sh" as your shell,
then create a "~/.profile" file to launch zsh as a login shell with the
following line:
exec /var/run/current-system/sw/bin/zsh -l
inside. This way, bash will first properly read /etc/bashrc, etc. when
you log in, since "/bin/sh" is symlinked to bash (bash sources
/etc/bashrc by design) and the PATHs won't be broken for your zsh
session.
I'm not sure if my understanding is correct, but hey, at least it worked
for me!
-Linus
More information about the nix-dev
mailing list