Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing doesnt work under fish shell #1512

Closed
cbarrett opened this issue Aug 13, 2017 · 64 comments · Fixed by #7014
Closed

Installing doesnt work under fish shell #1512

cbarrett opened this issue Aug 13, 2017 · 64 comments · Fixed by #7014
Assignees

Comments

@cbarrett
Copy link

cbarrett commented Aug 13, 2017

steps to reproduce:

  1. Install fish shell, set it as your login shell
  2. $ curl -o install-nix https://nixos.org/nix/install
  3. $ sh ./install
  4. Proceed through the prompts
  5. Open a new terminal
  6. $ nix-shell -p figlet -p lolcat --run "echo 'nix rules' | figlet | lolcat"
    (As is suggested by the installer)

expected results:

it works!

actual results:

fish: Unknown command 'nix-shell'

notes

a warning would be appreciated if running under an unsupported shell

macOS Sierra 10.12.6, fish 2.4.0

@ridiculousfish
Copy link

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.

@cbarrett
Copy link
Author

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

@cbarrett
Copy link
Author

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

@cbarrett
Copy link
Author

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

@cbarrett
Copy link
Author

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) 😭

@cbarrett
Copy link
Author

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.

@cbarrett
Copy link
Author

I tried this, didnt work. Steps:

  1. $ bash -li
  2. $ sh ./install-nix
  3. Proceed thru prompts
  4. Source the nix-daemon.sh file as recommended by the installer
  5. $ nix-env -i fish
  6. $ sudo -e /etc/shells
  7. Add ~/.nix-profile/bin/fish, save & quit.
  8. $ chsh -s ~/.nix-profile/bin/fish
  9. Open a new terminal
  10. $ nix-shell

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

@copumpkin
Copy link
Member

Related: #440 #1090 #1087 #626 #545

Not sure where we stand now as I haven't read any of those in a long time 😄

@therealpxc
Copy link

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.

@cbarrett
Copy link
Author

@therealpxc Great! I'd love to. I'm on freenode, or we can email (see my github profile)

@therealpxc
Copy link

therealpxc commented Aug 23, 2017

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.

@peterromfeldhk
Copy link

im using fenv as workaround ;)

@spinningarrow
Copy link

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!

@JamesMcMahon
Copy link

@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?

@spinningarrow
Copy link

@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.

@spinningarrow
Copy link

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

@peterromfeldhk
Copy link

@JamesMcMahon https://github.com/oh-my-fish/plugin-foreign-env

@therealpxc
Copy link

therealpxc commented Jan 31, 2018

Goal in two parts

I'd like things to be so that:

  1. Fish installed via Nix always works with Nix, with no configuration required
  2. Nix includes 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).

Plans for each

I think we can do both of these pretty easily. Here's how:

Mostly-complete solution to the first part

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 some guidance and probably a tiny bit of coordination

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.

Wrapping profile.sh and friends

I 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.

A penny for your thoughts

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

  • how to expose the location of the profile.sh scripts to the fish package, and
    • what I really need to know here is how to start a discussion on the right way to standardize the locations of the relevant scripts, if we can just expose a NIX_STATE in stdenv like NIX_STORE, or what
  • whether we can include fish-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?

@MaxGabriel
Copy link

I'm a new Nix user and just ran into this issue. Is this a correct summary of what to do?

  1. Uninstall Nix (I installed with fish, and I don't think the necessary changes were made to the .bash type files, because I get the same error message with bash).
  2. Reinstall Nix using bash
  3. Either:
    • Start my shells using bash -cl fish. Not sure if this is possible with iTerm but it sounds doable
    • OR Install fenv, and in my config.fish file, use it to run nix.sh and nix-daemon.sh to get the environment variables from them.

@spinningarrow
Copy link

spinningarrow commented Mar 14, 2018

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)

@MaxGabriel
Copy link

@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

@MaxGabriel
Copy link

MaxGabriel commented Mar 20, 2018

Ok here's what I did to get it working:

  1. Temporarily change my login shell to bash. This seemed necessary to get my bash shells get the updates from /etc/bashrc, which is what the installer updates. Possibly the docs are wrong with regards to .bash_profile being changed?
  2. Install nix
  3. Install oh-my-fish, then fenv. I added this to my 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

@MaxGabriel
Copy link

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.

@therealpxc
Copy link

therealpxc commented Mar 20, 2018

@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!

@ridiculousfish
Copy link

ridiculousfish commented Mar 20, 2018

FYI this warning has been removed in fish 3.0, which is scheduled to be released in the near future (fish-shell/fish-shell@de8ccf1).

@MaxGabriel
Copy link

Awesome, looking forward to the new version @ridiculousfish

@sebastien
Copy link

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.

@fourdragons
Copy link

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!

@MaxGabriel
Copy link

MaxGabriel commented Jan 9, 2020

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.

@hedefalk
Copy link

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?

@tristanpemble
Copy link

tristanpemble commented Dec 17, 2020

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";
        };
      }
    ];
  };
}

@supermarin
Copy link

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.

@bbhoss
Copy link

bbhoss commented Feb 26, 2021

Is it possible to use fish shell with nix?

Edit: Seems like it is, you can install via curl -L https://nixos.org/nix/install | sh then using fisher add lilyball/nix-env.fish to fix the env instead of following the bash instructions

@debajyoti-thetaonelab
Copy link

Is it possible to use fish shell with nix?

Edit: Seems like it is, you can install via curl -L https://nixos.org/nix/install | sh then using fisher add lilyball/nix-env.fish to fix the env instead of following the bash instructions

The plugin lilyball/nix-env.fish works perfectly on my system (Ubuntu 20.04). Just that fisher add subcommand is not available anymore. Updated command would be

fisher install lilyball/nix-env.fish

@zarelit
Copy link
Member

zarelit commented Sep 21, 2021

So is this issue just a matter of documentation now?

@grerrg
Copy link

grerrg commented Oct 1, 2021

@zarelit IMHO it's not done jet. fish should be a first class citizien just like bashand zsh.

@supermarin
Copy link

+1 it's not done. The ENV files should either be provided redundantly for all shells or a different mechanism could be considered

@drupol
Copy link
Contributor

drupol commented Jan 31, 2022

I got this working with Fisher and https://github.com/lilyball/nix-env.fish plugin from @lilyball (Thanks!).

I think the nix installer should provide a default .fish file ready to use which would be the equivalent of the .sh file.

Maybe we should first update the documentation and then see how we can improve the installer?

Edit: I just updated the Wiki: https://nixos.wiki/wiki/Nix_Installation_Guide

@supermarin
Copy link

supermarin commented May 24, 2022

I'd still suggest not using any 3rd party plugins or parsers, especially if no other fish plugins are being used on the system. Here's an approach that works without plugins:

  1. Install nix normally
  2. chsh and set your shell to /run/current-system/sw/bin/bash
  3. Put exec fish in your ~/.profile

What happens is bash becomes your login shell and loads all the environment correctly. As soon as you open a new terminal window,exec replaces bash process with fish. You can still manually launch bash by typing bash from the running fish instance. There's no noticeable performance drawback.

@hgezim
Copy link

hgezim commented Aug 30, 2022

After installing bass, I added this to ~/.config/fish/config.fish

bass source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'

This is for the newer nix install for multi-users (Linux).

@grahamc
Copy link
Member

grahamc commented Sep 7, 2022

I think @Hoverbear and I solved this today. We'll be doing a bit more testing then submitting a PR tomorrow.

grahamc added a commit to DeterminateSystems/nix-src that referenced this issue Sep 13, 2022
Before this patch, installing Nix using the Fish shell did not
work because Fish wasn't configured to add Nix to the PATH. Some
options in NixOS#1512 offered workarounds, but they typically involve
extra plugins or packages.

This patch adds native, out-of-the-box support for the Fish shell.

Note that Fish supports a `conf.d` directory, which is intended
for exactly use cases like this: software projects distributing
shell snippets. This patch takes advantage of it. The installer
doesn't append any Nix loader behavior to any Fish config file.
Because of that, the uninstall process is smooth and a reinstall
obliterates the existing nix.fish files that we place instead of
bothering the user with a backup / manual removal.

Both single-user and multi-user cases are covered. It has been
tested on Ubuntu, and a Mac with MacPorts, homebrew, and the
Fish installer pkg.

Closes NixOS#1512

Co-authored-by: Graham Christensen <[email protected]>
grahamc pushed a commit to DeterminateSystems/nix-src that referenced this issue Sep 14, 2022
Before this patch, installing Nix using the Fish shell did not
work because Fish wasn't configured to add Nix to the PATH. Some
options in NixOS#1512 offered workarounds, but they typically involve
extra plugins or packages.

This patch adds native, out-of-the-box support for the Fish shell.

Note that Fish supports a `conf.d` directory, which is intended
for exactly use cases like this: software projects distributing
shell snippets. This patch takes advantage of it. The installer
doesn't append any Nix loader behavior to any Fish config file.
Because of that, the uninstall process is smooth and a reinstall
obliterates the existing nix.fish files that we place instead of
bothering the user with a backup / manual removal.

Both single-user and multi-user cases are covered. It has been
tested on Ubuntu, and a Mac with MacPorts, homebrew, and the
Fish installer pkg.

Closes NixOS#1512

Co-authored-by: Graham Christensen <[email protected]>
(cherry picked from commit 8ebdbeb)
@haarts
Copy link

haarts commented Sep 14, 2022

Most excellent!

@grahamc I believe it is you who authored the commit. Where would I send the Bitcoin (perhaps best if you contact me in a DM)?

@grahamc
Copy link
Member

grahamc commented Sep 14, 2022

@haarts thanks for offering! Perhaps you could instead make a recurring contribution to the NixOS Foundation? :)

@haarts
Copy link

haarts commented Sep 14, 2022

I'll do that then. Thank you very much for your efforts!

@haarts
Copy link

haarts commented Sep 14, 2022

Done

@grahamc
Copy link
Member

grahamc commented Sep 14, 2022

Thank you!

Minion3665 pushed a commit to Minion3665/nix that referenced this issue Feb 23, 2023
Before this patch, installing Nix using the Fish shell did not
work because Fish wasn't configured to add Nix to the PATH. Some
options in NixOS#1512 offered workarounds, but they typically involve
extra plugins or packages.

This patch adds native, out-of-the-box support for the Fish shell.

Note that Fish supports a `conf.d` directory, which is intended
for exactly use cases like this: software projects distributing
shell snippets. This patch takes advantage of it. The installer
doesn't append any Nix loader behavior to any Fish config file.
Because of that, the uninstall process is smooth and a reinstall
obliterates the existing nix.fish files that we place instead of
bothering the user with a backup / manual removal.

Both single-user and multi-user cases are covered. It has been
tested on Ubuntu, and a Mac with MacPorts, homebrew, and the
Fish installer pkg.

Closes NixOS#1512

Co-authored-by: Graham Christensen <[email protected]>
@davinkevin
Copy link

FYI, I had to use https://github.com/lilyball/nix-env.fish/tree/master/conf.d to make it work because my installation hasn't been detected correctly by the nix-installer. Maybe something for you @grahamc?

I would be happy to provide extra info if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.