nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.98k stars 1.8k forks source link

fish: plugins should have access to home-manager environment #3174

Open metiulekm opened 2 years ago

metiulekm commented 2 years ago

Description

Currently, the plugins are loaded using files in conf.d, and most other things, in particular hm-session-vars.sh, are loaded in config.fish. Since conf.d is processed before config.fish, this means that plugins are loaded before hm-session-vars.sh, which means that they will not have access to most of the configured environment.

As a concrete example (and my usecase), one might try using https://github.com/oh-my-fish/plugin-grc together with home.packages = [pkgs.grc];. However, that plugin checks if grc binary is available as part of its initialization (see https://github.com/oh-my-fish/plugin-grc/blob/61de7a8a0d7bda3234f8703d6e07c671992eb079/conf.d/grc.fish#L1). Since the hm-session-vars.sh will only be called after the plugin initialization, grc won't be available yet, and so this check will fail and the plugin will not do anything unless a child fish process is launched.

stale[bot] commented 1 year ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

tcoopman commented 1 year ago

is there any workaround for this at the moment?

metiulekm commented 1 year ago

is there any workaround for this at the moment?

My workaround was to stop using grc :) I did not try this (EDIT: I just resetup grc this way and it works perfectly, thanks for inspiring me! :)), but setting up both Bash and Fish, and then calling into Fish from Bash (either by a manual exec fish or by having something in .bashrc) could work. This is probably a good idea anyway for various reasons (/etc/profile, corporate wants to set your shell in AD, you don't want to install Fish globally and if you do it might be the wrong version etc.) but is mildly tedious.

Honestly allowing the behavior I wanted feels quite easy, but the current behavior seems quite intentional and I don't think I'd like to attempt this without maintainers saying something discussing it a bit.

stale[bot] commented 1 year ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.