nix-shell -p <some_pkg> not working with fish-shell #1131

Open
opened 2026-02-11 12:10:38 +00:00 by ddogfoodd · 5 comments

Describe the bug

nix-shell -p <some_pkg> doesn't work for my fish shell.
The installed package is not available and the prompt doesn't indicate that the nix-shell is active.

nix shell nixpkgs#<some_pkg> works as expected.

I have tried with Lix from nixpkgs stable, latest and git using the "Advanced change" described here: https://lix.systems/add-to-config/

Works on vanilla nix.

Steps To Reproduce

  1. Use Lix stable, latest or git
  2. Enable fish-shell
  3. Try nix-shell -p <some_pkg>
  4. Package is not available and there is no indicator for the active nix-shell

Expected behavior

I expected an indicator for the active nix-shell to appear and the package to be available. Like with nix shell or vanilla nix.

nix --version output

Stable

nix (Lix, like Nix) 2.94.0
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/jost/.config/nix/nix.conf:/nix/store/1x3a3vy8y7ii61xbn871nlnnkpd57lsy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jost/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jost/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jost/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/azm88nn29hmfnrrmh1rv0wp32a7kvwmd-lix-2.94.0/share

Latest

nix (Lix, like Nix) 2.94.0
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/jost/.config/nix/nix.conf:/nix/store/1x3a3vy8y7ii61xbn871nlnnkpd57lsy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jost/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jost/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jost/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/azm88nn29hmfnrrmh1rv0wp32a7kvwmd-lix-2.94.0/share

Git

nix (Lix, like Nix) 2.95.0
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/jost/.config/nix/nix.conf:/nix/store/1x3a3vy8y7ii61xbn871nlnnkpd57lsy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jost/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jost/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jost/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/0rg35jcbwjcim8di5d97fqvxa3mzjcqp-lix-2.95.0-pre-20260103_d387c9113c73/share

Additional context

fish-shell 4.4.0

## Describe the bug `nix-shell -p <some_pkg>` doesn't work for my `fish` shell. The installed package is not available and the prompt doesn't indicate that the nix-shell is active. `nix shell nixpkgs#<some_pkg>` works as expected. I have tried with Lix from nixpkgs `stable`, `latest` and `git` using the "Advanced change" described here: https://lix.systems/add-to-config/ Works on vanilla nix. ## Steps To Reproduce 1. Use Lix `stable`, `latest` or `git` 2. Enable fish-shell 3. Try `nix-shell -p <some_pkg>` 4. Package is not available and there is no indicator for the active nix-shell ## Expected behavior I expected an indicator for the active nix-shell to appear and the package to be available. Like with `nix shell` or vanilla nix. ## `nix --version` output ### Stable ``` nix (Lix, like Nix) 2.94.0 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/jost/.config/nix/nix.conf:/nix/store/1x3a3vy8y7ii61xbn871nlnnkpd57lsy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jost/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jost/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jost/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/azm88nn29hmfnrrmh1rv0wp32a7kvwmd-lix-2.94.0/share ``` ### Latest ``` nix (Lix, like Nix) 2.94.0 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/jost/.config/nix/nix.conf:/nix/store/1x3a3vy8y7ii61xbn871nlnnkpd57lsy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jost/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jost/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jost/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/azm88nn29hmfnrrmh1rv0wp32a7kvwmd-lix-2.94.0/share ``` ### Git ``` nix (Lix, like Nix) 2.95.0 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/jost/.config/nix/nix.conf:/nix/store/1x3a3vy8y7ii61xbn871nlnnkpd57lsy-stylix-kde-config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/jost/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/jost/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/jost/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/0rg35jcbwjcim8di5d97fqvxa3mzjcqp-lix-2.95.0-pre-20260103_d387c9113c73/share ``` ## Additional context fish-shell 4.4.0
Owner

Hi, thanks for the report. I believe we have a bunch of users who are running fish and are not reproducing your bug.
Could you provide nix-shell -vvvvv -p a_package ?

Hi, thanks for the report. I believe we have a bunch of users who are running fish and are not reproducing your bug. Could you provide `nix-shell -vvvvv -p a_package` ?
Author

@raito wrote in #1131 (comment):

Hi, thanks for the report. I believe we have a bunch of users who are running fish and are not reproducing your bug. Could you provide nix-shell -vvvvv -p a_package ?

Sure!

@raito wrote in https://git.lix.systems/lix-project/lix/issues/1131#issuecomment-17541: > Hi, thanks for the report. I believe we have a bunch of users who are running fish and are not reproducing your bug. Could you provide `nix-shell -vvvvv -p a_package` ? Sure!
raito added this to the 2.96 milestone 2026-03-03 02:46:15 +00:00

I investigated this issue, and the problem originates from commit 12b87538e + following the instruction in NixOS wiki page to fish.

The setup in wiki page configures bash to launch fish, if bash is an interactive shell and if the parent process is not fish. The commit that I mentioned changes the behavior of nix-shell from directly executing execvp in the process into forking first and use the child process to exec the shell. As a result, the parent process is not fish anymore, but nix-shell.

I find the fish bootstrap introduced in the wiki page is pretty hacky, because if we run bash in a bash shell, we are gonna get fish shell instead. This is the "norm" in CppNix, but I don't really like this hack. I would prefer to just let my terminal start fish directly instead.

One possible "solution" is to patch the rcfile generated for the nix-shell, so that .bashrc is sourced after the variables setup (PATH etc.). This solution still starts fish, but has the package available. However, this changes the nix-shell semantic when compared to CppNix, since it now starts fish instead of bash.

I investigated this issue, and the problem originates from commit 12b87538e + following the instruction in NixOS wiki page to [fish](https://nixos.wiki/wiki/Fish). The setup in wiki page configures bash to launch fish, if bash is an interactive shell and if the parent process is not fish. The commit that I mentioned changes the behavior of nix-shell from directly executing `execvp` in the process into forking first and use the child process to exec the shell. As a result, the parent process is not `fish` anymore, but `nix-shell`. I find the fish bootstrap introduced in the wiki page is pretty hacky, because if we run `bash` in a bash shell, we are gonna get fish shell instead. This is the "norm" in CppNix, but I don't really like this hack. I would prefer to just let my terminal start fish directly instead. One possible "solution" is to patch the rcfile generated for the nix-shell, so that `.bashrc` is sourced after the variables setup (`PATH` etc.). This solution still starts fish, but has the package available. However, this changes the nix-shell semantic when compared to CppNix, since it now starts fish instead of bash.

@raito would you like to discuss about how we want to solve this issue? I am willing to work on this

@raito would you like to discuss about how we want to solve this issue? I am willing to work on this
Owner

@s1syph0s Yes, absolutely. I'm just not super familiar with fish; what if we do the solution you suggest of patching the rcfile, how can we evaluate the semantical change has no impact on the rest of the ecosystem (direnv, devenv, etc.)?

@s1syph0s Yes, absolutely. I'm just not *super* familiar with fish; what if we do the solution you suggest of patching the rcfile, how can we evaluate the semantical change has no impact on the rest of the ecosystem (direnv, devenv, etc.)?
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1131
No description provided.