LnL7 / nix-darwin

nix modules for darwin
MIT License
2.76k stars 428 forks source link

Clarify support for fish shell #515

Open jab opened 2 years ago

jab commented 2 years ago

I recently installed nix-darwin for the first time. The installer mentioned that it was modifying config for bash and zsh to interoperate with nix, but it didn't say anything about fish, so I'm not sure to what extent fish is supported, and what steps I need to take to use nix-darwin-provided fish as my default shell.

I tried adding pkgs.fish to environment.systemPackages and setting programs.fish.enable = true in my darwin-configuration.nix, then running darwin-rebuild switch && echo /run/current-system/sw/bin/fish > /etc/shells && chsh -s /run/current-system/sw/bin/fish, and finally opening a new terminal window, and immediately hit #122, so fish was unusable out-of-the-box. Once I added this workaround I got it working.

  1. Since the installer mentions bash and zsh, would it be worth mentioning fish as well (even if only to parenthetically say e.g. "If you want to use fish, see #122" (or whatever other link makes sense) until there's better support for fish, since there are quite a few fish users out there who might have a similar experience?
  2. If the steps I took (above) for setting up nix-darwin-provided fish as my shell were correct, want me to contribute them somewhere that would be more discoverable to fish users than here? If they weren't correct, if I find out what the correct steps are I could write those down somewhere better instead.

Thanks for maintaining nix-darwin!

dingyuchen commented 1 year ago

If the steps I took (above) for setting up nix-darwin-provided fish as my shell were correct, want me to contribute them somewhere that would be more discoverable to fish users than here? If they weren't correct, if I find out what the correct steps are I could write those down somewhere better instead.

I'm a very new nix user myself, but this is what I think is supposed to be the "nix" way:

  1. Adding pkgs.fish to https://daiderd.com/nix-darwin/manual/index.html#opt-environment.shells should add /run/current-system/sw/bin/fish to /etc/shells
  2. Set https://daiderd.com/nix-darwin/manual/index.html#opt-users.users._name_.shell to pkgs.fish

This got me a working fish with all the nix- and darwin- commands. Hope it helps

bestlem commented 1 year ago

@ dingyuchen I added the line environment.shells = [ pkgs.bashInteractive pkgs.zsh pkgs.fish ]; to my configuration.nix

Then ran ` nix build .#darwinConfigurations.utm-vm.system --extra-experimental-features nix-command --extra-experimental-features flakes

./result/sw/bin/darwin-rebuild switch --flake . `

I got the shells added to /etc/shells by programs.fish.enable etc.

What exactly do you have to do? (environment.systemPackages is loading things so some of my config works)