Change sh symlink default shell

How to change default shell to something like dash?
I tried this line:

  environment.binsh = "${pkgs.dash}/bin/dash";

But, it doesn’t work.

  1. What do you mean by “Doesnt work”?
  2. A users loginshell is set via users.users.<name>.shell
  3. The shell for all users via users.defaultUserShell
  4. environment.binsh is a footgun.
{ pkgs, ... }:
{
  environment.shells = [ pkgs.dash ];
  users.defaultUserShell = pkgs.dash;
}

I built it with dash option but realpath $(which sh) command still returns bash.

In what environment? And did you reboot? I am not sure whether this has immediate effect or requires a reboot.

Though you really do not want to change this. Stuff will break!

For some fucking reason bash’ and dashsh are not compatible.

1 Like

Exactly.

❯ nixos-rebuild repl -f ~/src/mine/nixnix -A lamorna.system
building Nix...
Nix 2.28.5
Type :? for help.
Loading installable 'lamorna.system'...
Added 6 variables.
nix-repl> :p options.environment.binsh.description
The shell executable that is linked system-wide to
`/bin/sh`. Please note that NixOS assumes all
over the place that shell to be Bash, so override the default
setting only if you know exactly what you're doing.


nix-repl> :p options.environment.binsh.visible    
false

These are pretty strong hints that you want @FrdrCkII changes instead.

2 Likes