Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

What is the correct way to set fish as the user's default shell? #779

Closed
dstcruz opened this issue Sep 14, 2023 · 4 comments
Closed

What is the correct way to set fish as the user's default shell? #779

dstcruz opened this issue Sep 14, 2023 · 4 comments

Comments

@dstcruz
Copy link
Contributor

dstcruz commented Sep 14, 2023

After digging around, I'm still not able to get the user's default shell to point to fish. Regardless of what I try, the following command always reports zsh:

> dscl . -read ~/ UserShell
UserShell: /bin/zsh

> echo $SHELL
/bin/zsh

Here are the things I have tried:

  • Setting environment.loginShell = "${pkgs.fish}/bin/fish -l"; after adding pkgs.fish to environment.shells, following the example provided in modules/examples/lnl.nix.
  • Setting environment.loginShell = pkgs.fish; as I have found user configs in GitHub that are using that, but no dice.
  • Setting programs.fish.enable = true; as this seems to work for zsh but not for fish (see $SHELL is not set properly for fish #146).
  • Setting users.users.my-user.shell = pkgs.fish; this seems to do nothing.
  • Setting programs.fish.enable = true; in my home-manager section. Tried this just in case. Does not change UserShell. My understanding is that home-manager might not be able to set the user's shell as that requires root (??).

At this point, I have to manually use chsh -s /run/current-system/sw/bin/fish. If that's what is required it would be nice to have that documented somewhere. None of the fish related issues explicitly say that "that's the right way to do it", only that that's what people are using to force the change.

Also, while digging around, it seems that environments.loginShell is defined in line 79 of modules/environment/default.nix, but I could not find anywhere where it is actually used. Did I miss something?

@Enzime
Copy link
Collaborator

Enzime commented Sep 14, 2023

The environment.loginShell option should be renamed as it is only used for tmux, and currently the only way to set the shell is using users.users.<user>.shell but that will only execute if a user doesn't already exist and is added to users.knownUsers. This means currently nix-darwin doesn't have a good way of controlling a user's shell.

I'm going to close this issue as it is a duplicate of these 2 existing issues: #361 #328

@Enzime Enzime closed this as completed Sep 14, 2023
@iriscanavan
Copy link

iriscanavan commented Jul 18, 2024

At this point, I have to manually use chsh -s /run/current-system/sw/bin/fish.

I have the same issue, but how would chsh -s /run/current-system/sw/bin/fish work here since /run/current-system/sw/bin/fish a symlink to the Nix store?

@ian-h-chamberlain
Copy link
Contributor

I have the same issue, but how would chsh -s /run/current-system/sw/bin/fish work here since /run/current-system/sw/bin/fish a symlink to the Nix store?

This worked for me, I had to manually append /run/current-system/sw/bin/fish to /etc/shells as well first. I guess the OS doesn't have a problem with symlink shells as long as they actually exist?

@Enzime
Copy link
Collaborator

Enzime commented Oct 31, 2024

Updating /etc/shells manually or via environment.shells should no longer be necessary since #1118 as long as you set the shell you want to use with users.users.<user>.shell = pkgs.fish;

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants