dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.79k stars 113 forks source link

Fish shell doesn't set PATH correctly? #103

Closed victorhooi closed 3 months ago

victorhooi commented 4 months ago

I use the fish shell - and for some reason, the PATH isn't set correctly for Nix.

This causes issues like if you try to use fish and atuin together, and set fish as your default shell - you get the following 20 lines of errors printed out every time you try to open a new terminal, or try to run any command:

Last login: Tue Jul 16 22:17:15 on ttys004
fish: Unknown command: atuin
- (line 1): 
atuin uuid
^~~~^
in command substitution
    called on line 1 of file -
from sourcing file -
    called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
- (line 1): Unknown command
set -gx ATUIN_SESSION (atuin uuid)
                      ^~~~~~~~~~~^
from sourcing file -
    called on line 43 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

Here is my home-manager configuration - I have both fish and atuin enabled through that: modules/shared/home-manager.nix modules/darwin/home-manager.nix

I did noticed that my ~/.zshrc has this at the top:

❯ cat ~/.zshrc

if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]]; then
  . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
  . /nix/var/nix/profiles/default/etc/profile.d/nix.sh
fi

This seems to be done here.

Do you simply need to put in the corresponding equavilent for fish somehow?

This Reddit thread seems to imply that if you use nix-darwin, you shouldn't need to do anything special to set the fish path - but obviously that doesn't seem to be the case here. Or am I missing something?

victorhooi commented 4 months ago

I did try adding the below to my modules/shared/home-manager.nix, with the fish loginShellInit section:

  atuin = {
    enable = true;
    enableBashIntegration = true;
    enableFishIntegration = true;
  };
  fish = {
    enable = true;
    loginShellInit = ''
      if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]]; then
        . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
        . /nix/var/nix/profiles/default/etc/profile.d/nix.fish
      fi
   '';
  };

  starship = {
    enable = true;
  };

However, the issue with the atuin error message still seemed to occur - so it doesn't look like that worked =(.

dustinlyons commented 4 months ago

@victorhooi This is somewhat out of this project's scope, as the configuration is mostly concerned with getting users up and running. Then the whole world of Nix is exposed, which has some rough edges ;)

I don't know much about the fish shell, unfortunately. Here is the actual home-manager module file, which will show you what options are available:

https://github.com/nix-community/home-manager/blob/master/modules/programs/fish.nix

Doesn't look like this includes the loginShellInit option.

You may have success asking for help on the nixpkgs repository, if this is indeed an error that is impacting everyone. Or search Github for other users who have the fish shell enabled, to validate your understanding:

https://github.com/search?q=programs.fish%20%3D%20%7B%20path%3A*.nix&type=code