Nix on other distro, issue with path and shell

Hello,

I installed nix on a ubuntu server to have my environment which include nushell. The installation went well (after some headache) and I defined the shell with /etc/shell and chsh -s /home/user/.nix-profile/bin/nu but then it doesn’t have the full path. And both zoxide and nix are known command. But this works if, from that shell, I do bash then nu. So if I go through bash and recreate a shell nu.
Isn’t that hwo I’m supposed to define the user shell ?

I’m not aware of any shell that just automagically knows how to search some nix profile path for executables. This job generally falls to a shell profile script/hook (which sets up the PATH along with a few other envs).

Non-POSIX shells tend to need their own profile/hook since they tend to have incompatible syntax, and there isn’t yet a nushell profile script for nix. (see Installer nushell support by Eternahl · Pull Request #10439 · NixOS/nix · GitHub)

Basically, it works when you run it from bash because it’s inheriting the already-configured environment from bash.

1 Like

Depending on how you installed Nix, it will have edited files read by bash, but probably not nu :

The install script will modify the first writable file from amongst .bash_profile, .bash_login and .profile to source ~/.nix-profile/etc/profile.d/nix.sh. You can set the NIX_INSTALLER_NO_MODIFY_PROFILE environment variable before executing the install script to disable this behaviour.

or

The installer will modify /etc/bashrc, and /etc/zshrc if they exist. The installer will first back up these files with a .backup-before-nix extension. The installer will also create /etc/profile.d/nix.sh.

2 Likes