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

fish: Don't source the Nix configuration if it already has been sourced #48

Closed
cbarrett opened this issue Oct 6, 2017 · 8 comments
Closed

Comments

@cbarrett
Copy link
Contributor

cbarrett commented Oct 6, 2017

(Part of the effort to kill this line of code dead.)

@therealpxc
Copy link

All of the Nix environment setup scripts I've seen (in the nix.sh script of GNU+Linux, the environment on NixOS, the nix-daemon.sh script on macOS, and in nix-darwin) set PATH this way. I think it makes sense on initial startup, but we have to make sure it runs as early as possible and never twice. Take a look at the NixOS module for Fish and the fish package in nixpkgs for an example.

I think if we change the Fish package to source /etc/static/preinit-whatever.fish instead of in plain /etc, then nix-darwin can put the file in place and NixOS should be unaffected. Right now nix-darwin can't put the file where Fish expects because it doesn't (and shouldn't) own /etc.

@cbarrett
Copy link
Contributor Author

cbarrett commented Oct 6, 2017

@therealpxc That makes sense to me, I think. I understand what the NixOS things in the Fish package are doing, at any rate.

How do you suggest managing the tickets for this?

@therealpxc
Copy link

I think we should make the changes we want on the Nixpkgs side on a local checkout while we work out the nix-darwin stuff, then submit the PRs for both pieces. That way the PR for Nixpkgs can say 'this makes the following achievable in nix-darwin' instead of 'we hope this will enable us to do xyz for nix-darwin'.

@cbarrett
Copy link
Contributor Author

cbarrett commented Oct 6, 2017

@therealpxc Sounds good to me.

What the fish package does looks reasonable to me. I'm assuming we don't export the _fish_nixos*_sourced variables because the idea is that we reset things anew in subshells anyway?

@LnL7
Copy link
Owner

LnL7 commented Oct 6, 2017

The other shell modules do something similar, but how is this related to setting PATH?

@therealpxc
Copy link

@cbarrett that's right.

@LnL7 The way that PATH is set is neither by appending nor pre-pending but straight-up setting PATH, so that if the Nix configuration stuff gets sourced after other things (like nix-shell, for example) try to set the PATH, it will be erased.

Since EDITOR also gets set this way, for example, it overrides the ~/.config/fish/conf.d/env.fish snippet I have which sets it to vim, so I have to re-override it at the end ~/.config/fish/config.fish, which gets sourced later, as a workaround.

@therealpxc
Copy link

And to make Nix-installed CLI programs available to snippets in ~/.config/fish/conf.d and directories like it, the Nix stuff has to be sourced prior to shell initialization proper, which is what the preinit stuff in the Fish package and NixOS module take care of. This is because the conf.d stuff is sourced before config.fish and in alphanumeric order, so adding a Fish snippet for Nix init doesn't guarantee that it will execute first either.

@LnL7
Copy link
Owner

LnL7 commented Nov 6, 2017

Fixed by #50

@LnL7 LnL7 closed this as completed Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants