-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
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 |
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: Some other commands I ran:
|
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 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 |
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 An out of the box solution would be perfect, though! |
@peterromfeldhk what is "fenv"? @spinningarrow Where are you putting 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 |
Goal in two partsI'd like things to be so that:
Plans for eachI think we can do both of these pretty easily. Here's how: Mostly-complete solution to the first partI have worked out some changes to the That solution currently has (imo) one major defect which definitely makes it unmergeable: it relies on the location of the I need some guidance and probably a tiny bit of coordinationI need (I think) Nix to expose something about the path to the default profile or to this script for my changes to the Wrapping
|
I'm a new Nix user and just ran into this issue. Is this a correct summary of what to do?
|
For what it's worth, I installed Nix with fish but it installed correctly for bash (since you do What you mentioned in step 3 sounds about right to me! (I'm not familiar with |
@spinningarrow Thanks! I think the reason that it didn't install correctly for me through even bash is that I don't have a |
Ok here's what I did to get it working:
Now everything seems to be working EDIT: I recently installed macOS Mojave and reinstalled Nix. Instead of the So instead you'll use that in your
|
Note, after installing I got these warnings from fish:
You can fix the first one by installing any software (e.g. The second two are a little weird. Inside |
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 (fish-shell/fish-shell@de8ccf1). |
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 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:
This gives me access to the For example, after running
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
|
I'm using bax to source nix on a Mac. I've been using this:
This part of nix.sh doesn't get exported:
The other env is correctly exported but just NIX_PATH is not. Current workaround is just to do:
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
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 |
Is it possible to use fish shell with nix? Edit: Seems like it is, you can install via |
The plugin lilyball/nix-env.fish works perfectly on my system (Ubuntu 20.04). Just that fisher install lilyball/nix-env.fish |
So is this issue just a matter of documentation now? |
@zarelit IMHO it's not done jet. |
+1 it's not done. The ENV files should either be provided redundantly for all shells or a different mechanism could be considered |
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 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 |
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:
What happens is bash becomes your login shell and loads all the environment correctly. As soon as you open a new terminal window, |
After installing bass, I added this to
This is for the newer nix install for multi-users (Linux). |
I think @Hoverbear and I solved this today. We'll be doing a bit more testing then submitting a PR tomorrow. |
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]>
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)
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)? |
@haarts thanks for offering! Perhaps you could instead make a recurring contribution to the NixOS Foundation? :) |
I'll do that then. Thank you very much for your efforts! |
Done |
Thank you! |
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]>
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. |
steps to reproduce:
(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
The text was updated successfully, but these errors were encountered: