it works!
fish: Unknown command 'nix-shell'
a warning would be appreciated if running under an unsupported shell
macOS Sierra 10.12.6, fish 2.4.0
I haven't looked into how the nix installer works, but fish shell supports the /etc/paths and /etc/paths.d machinery on macOS. That may be an avenue to broaden support without needing to modify users startup scripts.
Looks like the installer script is here. https://github.com/NixOS/nix/blob/master/scripts/install-darwin-multi-user.sh Not sure where the nix-daemon.sh script comes from
It does look like there's a lot of supporting scripts and such in the fish package. https://github.com/NixOS/nixpkgs/blob/e0e6f46cd8122c8f68448e8a6d1626edeba417d3/pkgs/shells/fish/default.nix
This file contains some of the initialization that Fish under NixOS does. It looks like its utilizing the fish-foreign-env nixpkg (derived from that oh-my-fish plugin it seems) https://github.com/NixOS/nixpkgs/blob/7e40287d00e39bed522c59da805d20c298699411/nixos/modules/programs/fish.nix
I still havent been able to track down where the /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh script originates (the one that gets appended to the POSIX shells' profiles) 😭
Today I'm going to try setting bash to my login shell, installing nix, installing fish thru nix, and then setting that fish to my login shell.
Byzantine but if it works at least I am up and running.
I tried this, didnt work. Steps:
Outputs:
fish: Unknown command 'nix-shell'
Some other commands I ran:
cbarrett@Lexx ~> echo $PATH
/Users/cbarrett/.opam/4.02.3+buckle-1/bin /Users/cbarrett/Library/Android/sdk/tools /Users/cbarrett/Library/Android/sdk/platform-tools /Users/cbarrett/.fastlane/bin /Users/cbarrett/.local/bin /Users/cbarrett/.cabal/bin /Users/cbarrett/Applications/ghc-7.10.3.app/Contents/bin /opt/local/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /opt/X11/bin /usr/local/go/bin /Library/TeX/texbin
cbarrett@Lexx ~> echo $SHELL
/Users/cbarrett/.nix-profile/bin/fish
Related: https://github.com/NixOS/nix/issues/440 https://github.com/NixOS/nix/pull/1090 https://github.com/NixOS/nix/pull/1087 https://github.com/NixOS/nix/pull/626 https://github.com/NixOS/nix/pull/545
Not sure where we stand now as I haven't read any of those in a long time 😄
It has a few issues with clobbering the existing configs with the Nix ones so that if you use configuration snippets, you'll have to source them again at the end of your ~/.config/fish/config.fish or add equivalents there, but I'm currently using nix-darwin to use fish as my login shell on macOS.
Let me know whether you'd like to give that a try, @cbarrett, and if not I'll see how else we can get you a better fish experience on macOS.
@therealpxc Great! I'd love to. I'm on freenode, or we can email (see my github profile)
Cool. You can find me on Freenode as pxc. I'm idling in #nixos most of the time, including right now. Feel free to mention me in the channel if you have a general question or direct message me. Nix users on Mac also have their own channel on Freenode, ##nix-darwin, and you can find me idling in there also.
im using fenv as workaround ;)
As a workaround, I'm able to get this to work by setting my shell command in the terminal (or tmux in my case) to bash -cl fish. With that I have access to nix-shell, nix-env and so on in my terminal.
An out of the box solution would be perfect, though!
@peterromfeldhk what is "fenv"?
@spinningarrow Where are you putting bash -cl fish?
Basically trying to figure out the work arounds people are using. Is there any official word on Nix / fish compatibility?
@JamesMcMahon essentially I’ve got my terminal app and tmux to start with the command ‘bash -cl fish’ instead of the default user shell.
I would definitely prefer official compatibility instead of this workaround though.
I realize that I essentially paraphrased my previous comment without reading it. Here’s the tmux configuration I’m using: https://github.com/spinningarrow/.files/blob/master/tmux/.tmux.conf#L6
@JamesMcMahon https://github.com/oh-my-fish/plugin-foreign-env
I'd like things to be so that:
nix.fish and nix-daemon.fish scripts which use our existing fish-foreign-env package from Nixpkgs to wrap the POSIX scripts we use to set up environments for the other shells, just like we do on NixOS. All the real logic for setting up the environment stays in nix.sh and nix-daemon.sh so we don't have much more to maintain. We use the same fenv as NixOS so we benefit from its fixes (which are admittedly only cosmetic right now). I think we can do both of these pretty easily. Here's how:
I have worked out some changes to the fish package in Nixpkgs which achieve (1). It makes it so that Fish always loads the Nix environment (via fenv) prior to the rest of shell initialization, so it doesn't clobber any variables and everything installed via Nix is available on your PATH for even the first-loaded snippets in ~/.config/fish/conf.d, etc.
That solution currently has (imo) one major defect which definitely makes it unmergeable: it relies on the location of the nix.sh and nix-daemon.sh files being under /nix/var/nix/..., which will not be the case for Nix compiled with the option to put it somewhere else.
I need (I think) Nix to expose something about the path to the default profile or to this script for my changes to the fish package to be safe and robust. I don't know what those should be or who to ask. One thought that occurred to me is the Nix 'state dir' (/nix/var/nix). This is discussed in my PR (if you take a look, feel free to skip most of the discussion and just look at the comments on the code), so please reach out to me there.
profile.sh and friendsI don't know what the policy is on including something from Nixpkgs in the Nix tarball, but the foreign environment plugin for _Oh My Fish!_ is tiny; it's just a fish script. We could move it into the Nix repo if we had to. Since most of the logic can be shared with NixOS and fish package, this piece would be trivial.
What do you think? @Mic92 @FRidh, I've interacted with you before and you've worked on the nix-profile.sh.in files relatively recently, and I'm otherwise not sure who to contact. Can you help me figure out
profile.sh scripts to the fish package, andNIX_STATE in stdenv like NIX_STORE, or whatfish-foreign-env with Nix?For the users and anyone else: what do you think of the goals I stated here? Do they sound useful? Is the approach suggested (use fenv as we do on NixOS) reasonable?
I'm a new Nix user and just ran into this issue. Is this a correct summary of what to do?
.bash type files, because I get the same error message with bash).bash -cl fish. Not sure if this is possible with iTerm but it sounds doablefenv, and in my config.fish file, use it to run nix.sh and nix-daemon.sh to get the environment variables from them.For what it's worth, I installed Nix with fish but it installed correctly for bash (since you do curl https://nixos.org/nix/install | sh to install, it uses sh and it shouldn't really matter what the parent shell that invokes that command is).
What you mentioned in step 3 sounds about right to me! (I'm not familiar with fenv though)
@spinningarrow Thanks! I think the reason that it didn't install correctly for me through even bash is that I don't have a .bash_profile, .bash_login or .profile file, which the docs say are the files the installer looks for to modify
Ok here's what I did to get it working:
.bash_profile being changed?config.fish file:# Nix
if test -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
end
# End Nix
Now everything seems to be working
EDIT:
I recently installed macOS Mojave and reinstalled Nix. Instead of the nix-daemon.sh path, instead repeat the instructions above and look at the path printed at the end of installation that it asks you to source: /Users/maximiliantagher/.nix-profile/etc/profile.d/nix.sh
So instead you'll use that in your config.fish file:
if test -e '/Users/maximiliantagher/.nix-profile/etc/profile.d/nix.sh'
fenv source '/Users/maximiliantagher/.nix-profile/etc/profile.d/nix.sh'
end
Note, after installing I got these warnings from fish:
Last login: Tue Mar 20 10:44:19 on ttys012
set: Warning: $PATH entry "/Users/maximiliantagher/.nix-profile/bin" is not valid (No such file or directory)
set: Warning: $PATH entry "/Users/maximiliantagher/.nix-profile/lib/kde4/libexec" is not valid (No such file or directory)
set: Warning: $PATH entry "/nix/var/nix/profiles/default/lib/kde4/libexec" is not valid (No such file or directory)
Welcome to fish, the friendly interactive shell
You can fix the first one by installing any software (e.g. nix-env -iA nixpkgs.tree). Before you do that, the .nix-profile is an invalid symlink.
The second two are a little weird. Inside /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh, at the very bottom of the file, the PATH is set to include those directories. I just deleted them from the list, since KDE is a Linux windowing system and I'm on macOS. Not sure why those are specifically hard-coded there.
@MaxGabriel
KDE is not a windowing system but a community which produces a whole suite of applications, many of which can be built and run on MacOS. The Plasma desktop environment, a product of this community, features a window manager called KWin. While you'll probably never run KWin on macOS, you might run Kate (an excellent graphical text editor) or Konsole.
You might still be right about their redundancy; I'm not sure which KDE applications are currently built for Darwin in Nixpkgs!
The reason those paths are included is so that you do not need to reload your shell to access binaries that Nix might place in those directories, should you choose to install some. Nix doesn't create the directories except to make way for contents in them, so they don't exist ahead of time.
Fish's warnings here are pointing out intended behavior, which is why we simply suppress the same messages in NixOS. They do not indicate a malfunction either of Fish or Nix. :-)
PS: Welcome to Nix community, in case no one has welcomed you already!
FYI this warning has been removed in fish 3.0, which is scheduled to be released in the near future (https://github.com/fish-shell/fish-shell/commit/de8ccf1751cdd55ef2ba37125bc23c4f7dd404a7).
Awesome, looking forward to the new version @ridiculousfish
For those interested, I wrote a script that automatically generates a Fish profile script from Nix's bash profile script. See https://gist.github.com/18a7eb71fdd34f6a0f825e69f9461d01 -- it might even be a good idea to include it in Nix's build system to generate the Fish configuration automatically.
I would suggest using https://github.com/edc/bass to source bash files into fish
works for me like a charm
@trollfred thanks! bass worked like a charm for me as well!
FYI thats how i install fish+nix on OSX (i know its not optimal using 2 different package managers to get the one i want lol) but then i use nix on OSX only for development (nix-shell) GUI apps i still install with brew cask
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install fish
sudo sh -c 'echo "/usr/local/bin/fish" >> /etc/shells'
chsh -s /usr/local/bin/fish
curl -L https://get.oh-my.fish | fish
omf install foreign-env
curl https://nixos.org/nix/install | sh
echo "fenv source $HOME/.nix-profile/etc/profile.d/nix.sh
set -xg LC_ALL en_US.UTF-8
set -xg LANG en_US.UTF-8
" > ~/.config/fish/config.fish
For those wondering _exactly_ how to use Nix and Bass together.
echo "bass source ~/.nix-profile/etc/profile.d/nix{,-daemon}.sh" >> ~/.config/fish/config.fish
This sources ~/.nix-profile/etc/profile.d/nix.sh and ~/.nix-profile/etc/profile.d/nix-daemon.sh through bass. Open a new Fish shell, echo $NIX_PATH should now output your nixpkgs path.
Maybe I'll give packaging bass for nix a try. Would be a step towards resolving this.
I've kinda lost interest in this because it was mostly just exciting when I was figuring out how it could work (I don't have a real need for it), but FWIW fenv is already packaged in Nix as fish-foreign-env and it does the same thing as bass. If we modify the fish package to install fenv in the system fish/functions.d directory, users can be instructed to add a fenv source... line like the bass source line above to their fish config.
But the problems of early initialization will still remain, so that anything sourced _before_ that fenv source or bass source line won't find any Nix-installed programs on its path, and may break because of it.
~/.config/fish/config.fish is the very last file sourced in the fish initialization procedure. So putting that line there will work, but if you have anything in ~/.config/fish/conf.d which expects a Nix-installed program to be there, it'll break (or at least complain) on startup. At present, that includes oh-my-fish for example.
For those wondering exactly how to use Nix and Bass together.
echo "bass source ~/.nix-profile/etc/profile.d/nix{,-daemon}.sh" >> ~/.config/fish/config.fishThis sources ~/.nix-profile/etc/profile.d/nix.sh and ~/.nix-profile/etc/profile.d/nix-daemon.sh through bass. Open a new Fish shell, echo $NIX_PATH should now output your nixpkgs path.
Is sourcing both of these actually correct? Does it work both when users have a running Nix daemon and when they don't? In bash, source --help prints:
source: source filename [arguments]
Execute commands from a file in the current shell.
Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.
Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.
So it looks like what that will actually do is source the first file in the expansion, to which it passes the second filename as an argument, which is then discarded. This will probably work on the default install since that uses the Nix daemon (on all platforms?) now, but it won't behave correctly when the daemon is not used.
~/.nix-profile/etc/profile.d/nix-daemon.sh is also not the correct location for a global installation of Nix; that'll only work for installations where fish is installed directly in that user's profile. For global installs, it'll end up under /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh.
I'm not sure if there's currently an actually-good way to tell whether we should source nix-daemon.sh vs. nix.sh, but one hacky way to tell that the daemon is enabled is if /etc/nix/nix.conf has a trusted-users = ... or an allowed-users = ... line in it.
Oh! One more thought: since
fish now supports && and ||, andfish comes with an export function that acts like bash's export, andcoreutils as part of the stdenv and the nix.sh script puts it on the PATH, andnix.sh nor nix-daemon.sh uses loops,if nix.sh and nix-daemon.sh are rewritten to use test ... && everywhere instead of if ...; then ...; fi..., we could technically source nix.sh and nix-daemon.sh from Fish.
Kinda weird and certainly brittle unless we got a commitment not to use loops in those files, but it would _work_.
My last effort to have a fish package in Nixpkgs which automatically Nixifies on all operating systems was stymied by two problems, and there was a third which produced awkwardness in determining which script of nix.sh and nix-daemon.sh to run:
set-environment script (the equivalent of nix-daemon.sh on NixOS) globally on NixOS was not well-received in code review and I didn't make a good enough case for it/nix/var/nix/profile/default/etc/profile.d/nix-daemon.sh is determined at compile time, and follows from what in Nix is called the ‘local state directory’, /nix/var/nix. A package that worked on custom Nix compilations would have to account for that, and we'd have to have the local state dir for a given version of Nix exposed in Nixpkgsnix-daemon socket, whose path is normally also determined by the state dir. Arguably, once the Nix local state dir is exposed, we can just source the appropriate file after checking the socket to see if a Nix daemon is running, and source the daemon script if it isThe first issue has actually already been resolved. So if someone wants to take up the torch for (1) exposing the Nix's local state dir in Nixpkgs as a standard and (2) making the location of the Nix daemon's socket a standard along the same lines, we can just tell Fish users ‘install Fish via Nix and that copy of Fish will set up the Nix environment for you before any config is sourced, preferring a running Nix daemon one is present’.
The work for that has mostly already been done, it just didn't make it through code review because there was concern that it was relying on implicit behavior and conventions of Nix and its config files, and I got bored/tired and wasn't motivated enough to keep arguing for standardizing those conventions. But it's extremely doable from a technical perspective.
I'm offering $100 equivalent in Bitcoin to properly fix this. And with properly I mean I can follow the install instructions while running Fish and it works.
i'm quite confused about this all too, some help woudl be appreciated :(
@haarts if it helps you, here's what I did after running the installer:
fisher add oh-my-fish/plugin-foreign-env
echo 'fenv source ~/.nix-profile/etc/profile.d/nix.sh' > ~/.config/fish/conf.d/00-nix.fish
I'm not sure this will be as complete of a solution like @therealpxc was pursuing, but it'd been good enough for me so far.
That'll more or less do it. :-)
As a slight variation, you can also grab the fenv stuff directly from Nixpkgs if you like, to get it without fisher or any shell framework. The one-liner is slightly hairy for portability reasons, but whatever:
sh -c '. "$HOME"/.nix-profile/etc/profile.d/nix.sh && nix run nixpkgs.coreutils -c install -m 644 -D "$(nix-build \'<nixpkgs>\' -A fish-foreign-env)"/share/fish-foreign-env/functions/*.fish -t "$HOME"/.config/fish/functions'
echo 'fenv source ~/.nix-profile/etc/profile.d/nix.sh' > ~/.config/fish/conf.d/00-nixify.fish
You should be able to run that first line from Fish or Bash or anywhere and get NixOS' slightly-modified fenv installed that way.
If your Nix setup is a multi-user install, you'll want instead:
sh -c '. /etc/profile.d/nix.sh && nix run nixpkgs.coreutils -c sudo install -m 644 -D "$(nix-build \'<nixpkgs>\' -A fish-foreign-env)"/share/fish-foreign-env/functions/*.fish -t /etc/fish/functions'
echo 'fenv source /etc/profile.d/nix.sh' | sudo tee /etc/fish/conf.d/00-nixify.fish
(Multi-user Nix installs create a /etc/profile.d/nix.sh file which, somewhat confusingly, sources the "${pkgs.nix}/etc/profile.d/nix-daemon.sh" file installed to the default profile.)
Is it only me or do you also get set: Tried to change the read-only variable “_” warning when statring new terminal after adding fenv source ~/.nix-profile/etc/profile.d/nix.sh to fish config ?
That happened with bass for me, but not with fenv. Perhaps you have an old
version?
On Wed, Apr 17, 2019, 08:29 Maciej Mazur notifications@github.com wrote:
Is it only me or do you also get set: Tried to change the read-only
variable “_” warning when statring new terminal after adding fenv source
~/.nix-profile/etc/profile.d/nix.sh to fish config ?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/NixOS/nix/issues/1512#issuecomment-483970801, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAlm1Wz1NaAkwD0HFPfCBIAAWRJxLbaks5vhs1TgaJpZM4O10T2
.
@pkoch @mamciek if you're using fenv from Nixpkgs, you get this patch which avoids incurring this warning, and another (removed in more recent Fish, IIRC) about setting a PATH which includes a non-existent directory.
I'd just install it using commands I posted above.
Alternatively, you can append ^ /dev/null to your entire fenv invocation.
Edited to add: maybe this fenv commit fixes the issue (and better)?
Thank you for the snippets and work here @therealpxc.
The one liners didn't quite work for me because I have some Frankenstein install on my macOS machine. I fear to imperatively fiddle with it given #2410 and other macOS specific issues.
I was able to get nix working with fish by installing oh-my-fish/plugin-foreign-env and then configuring my fish.config to load nix-daemon.sh
From a fish prompt on your macOS machine.
cd ~/.config/fishgit clone [email protected]:oh-my-fish/plugin-foreign-env.gitconfig.fish($HOME/.config/fish/config.fish) to do 2 things:fenv
# include this plugin so nix will work
# https://github.com/NixOS/nix/issues/1512
# https://github.com/oh-my-fish/plugin-foreign-env
set fish_function_path $fish_function_path $HOME/.config/fish/plugin-foreign-env/functions
fenv to source the nix-daemon.sh. You may need to adjust this path per what kind of install you have.
# initialize nix
fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
@efx For single-user installation this one works (replacement for the last line):
fenv source '$HOME/.nix-profile/etc/profile.d/nix.sh'
I learned pretty early on not to use Fish as my default shell. So I've been running Fish on top of Bash, then I drop out of Fish when I need to do something serious.
Being able to have Fish as my main/default shell would be awesome!
I was able to install nix under fish, using this trick in config.fish:
if test -e '/Users/maximiliantagher/.nix-profile/etc/profile.d/nix.sh'
fenv source '/Users/maximiliantagher/.nix-profile/etc/profile.d/nix.sh'
end
This gives me access to the nix-shell utility (/Users/maximiliantagher/.nix-profile/bin /Users/maximiliantagher/.nix-profile/bin is the front of the PATH), but when I actually open a nix-shell with fish the nix/store paths I need are getting added at the end.
For example, after running nix-shell --command zsh and doing echo $PATH the first item is /nix/store/r56rdhc3aa44xv7c6wrx0wwcs5inyap4-bash-interactive-4.4-p23/bin. But if I nix-shell --command fish, the path starts with /Users/maximiliantagher/.nix-profile/bin and doesn't get to the items in my nix/store until the end (after everything in /etc/paths
/Users/maximiliantagher/.nix-profile/bin /Users/maximiliantagher/.nix-profile/bin /Users/maximiliantagher/.local/bin /usr/local/bin /usr/local/sbin /usr/bin /bin /usr/sbin /sbin /Users/maximiliantagher/Documents/Mercury/mercury-web-backend2/bin /Users/maximiliantagher/Library/Python/2.7/bin /Users/maximiliantagher/.cabal/bin /Library/TeX/texbin . /nix/store/r56rdhc3aa44xv7c6wrx0wwcs5inyap4-bash-interactive-4.4-p23/bin /nix/store/qy1dj1b8gqczgfh7w756cdyz58jp406v-ghc-8.6.5-with-packages/bin /nix/store/p9f3m5l5dq89qzh79c25smld4l8nmn0p-ghc-8.6.5/bin /nix/store/36gia72i9xmakw4q20smbw6bqb7cp8lh-clang-wrapper-7.1.0/bin /nix/store/6f8xvcwbw5rp25rw7wm0c4sj17hi8lb9-clang-7.1.0/bin /nix/store/k3bjidcjf505g9pznksxz7dw9c8b55ip-coreutils-8.31/bin /nix/store/6sw407bcyi16znvagj9gqm2176ysmvp2-cctools-binutils-darwin-wrapper/bin /nix/store/adlsv1lf4c9aiqi0cqhvdbs54q70khdv-cctools-binutils-darwin/bin /nix/store/bxl4j4gb4djgz1c0c4jgcbynvg79lvk4-remove-references-to/bin /nix/store/1xkpnphya5zz2zzrvhd9q95s42h9gb5w-hpack-0.32.0/bin /nix/store/6va0v9fqbd2c8f2im57pjkd1sc3qznzs-ncurses-6.1-20190112/bin /nix/store/54h9dg33ym9lm3386j27q739h9gswync-libiconv-osx-10.12.6/bin /nix/store/993zr5zfrpmfls9mgzyjdlqh27s1a3fd-git-2.23.0/bin /nix/store/m5qgzmdcfnv32q9ch47bjp2kknrcbmmg-imagemagick-7.0.9-0-dev/bin /nix/store/pf4bqx7i6xf9ndxzy9z1mkkz1r313w2s-bzip2-1.0.6.0.1-bin/bin /nix/store/86hx5q8qmz1imx0sz0rwl0xb9wxccn8w-freetype-2.10.1-dev/bin /nix/store/cbxq1ia0wkvzqwq4d579vfh10qyf8gkf-libpng-apng-1.6.37-dev/bin /nix/store/c9spsdpl1j82nddisz9vk58igsc32nx4-libjpeg-turbo-2.0.3-bin/bin /nix/store/kxwy3pfza7brvq6vr68qcdv5ik3lw2g2-xz-5.2.4-bin/bin /nix/store/hvxrq05g968vqf1ycrmj0iwa88jrpr7a-libtiff-4.0.10-bin/bin /nix/store/jnmcn03v0hg7pga33jw17i7by1cdzx7d-lcms2-2.9-bin/bin /nix/store/1adgyhcjr5v5dqccr3j8inkgn45965qz-libwebp-1.0.3/bin /nix/store/yfxmixmd6yhgiqqj4cyq3l1vhlflr2q1-imagemagick-7.0.9-0/bin /nix/store/73cc227xnyshfk2xfsrwc8kxpncc3phs-ghostscript-9.26/bin /nix/store/c9323pfh0bfm9lk1flcmi4dxpr28ykm9-mercury-web-backend-gems/bin /nix/store/g7r6f507xm3hfrwb7k29n1hbpykksaik-ruby-2.6.5/bin /nix/store/crvlgkf22yw8rhk28gaws9qxhmqswk48-postgresql-11.5/bin /nix/store/mvijwqw2vh5956favmq37zwy9swpw1p8-utillinux-1003.1-2008/bin /nix/store/brzpxh07vcmdkyi6vislh88w10lhb9ji-findutils-4.7.0/bin /nix/store/607w8m5427nig4mmbd55mhhvy12ppmja-diffutils-3.7/bin /nix/store/ir7khmhbq9rwvmjck2ma0bm85rlqhmnw-gnused-4.7/bin /nix/store/hx446fzz34sjqrj4ivkh75p1im06wraj-gnugrep-3.3/bin /nix/store/pgw59kx6na7isiivah8djkhhnzjczan7-gawk-5.0.1/bin /nix/store/zp5v4pxypa4whsiq45cdsprsh7i3ky4s-gnutar-1.32/bin /nix/store/h1vcc1i59f7p6mlqhbkr4rl5sjkk00cg-gzip-1.10/bin /nix/store/rj16zdpyq9rasww22fmniy7vn60b5wrp-gnumake-4.2.1/bin /nix/store/mh5g5fj3jjwm60wfx9scr50cibx77m0s-bash-4.4-p23/bin /nix/store/qq5qhbxxbyl0lpx9yjvf3ai40hxh9g10-patch-2.7.6/bin /Users/maximiliantagher/.nix-profile/bin /Users/maximiliantagher/.config/fnm/bin .
Has anyone run into this? I think it started happening after an upgrade to fish 3.
Edit: confirmed, installed fish 2.7.1 and now /nix/store/ comes before my/etc/paths` in $PATH. Not sure if this is a bug or what. Maybe related to this item in the fish changelog:
/etc/paths is now parsed like macOS' bash path_helper, fixing $PATH order (#4336, #4852) on macOS.
I'm using bax to source nix on a Mac. I've been using this:
if test -e '/Users/viktor/.nix-profile/etc/profile.d/nix.sh'
bax source '/Users/viktor/.nix-profile/etc/profile.d/nix.sh'
end
This part of nix.sh doesn't get exported:
`export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels`
The other env is correctly exported but just NIX_PATH is not.
Current workaround is just to do:
if test -e '/Users/viktor/.nix-profile/etc/profile.d/nix.sh'
set -x NIX_PATH $NIX_PATH $HOME/.nix-defexpr/channels
bax source '/Users/viktor/.nix-profile/etc/profile.d/nix.sh'
end
I'm not sure what has changed because I've been using nix over fish successfully for quite some time now on different machines too, but this just turned up today for me… What happened was that nixpkgs wasn't defined:
file 'nixpkgs' was not found in the Nix search path
Any insight on this? I guess colon vs space separation or whatever might be the issue? But why did this turn up _now_?
home.nix for anyone who happens in here that is using Home Manager:
{ config, pkgs, ... }:
{
programs.fish = {
enable = true;
shellInit = ''
fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
'';
plugins = [
{
name = "plugin-foreign-env";
src = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-foreign-env";
rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc";
sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs";
};
}
];
};
}
The file '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' doesn't exist on my machine (macOS Big Sur, nix-darwin, home-manager), plus this requires installing fish plugins to handle env.
I believe this needs to be fixed as a first class support for fish, otherwise the experience is very unpleasant.
Most helpful comment
I'm offering $100 equivalent in Bitcoin to properly fix this. And with properly I mean I can follow the install instructions while running Fish and it works.