nix-community / home-manager

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

bug: Firefox search engines conflict in hm options and extensions #4243

Open midirhee12 opened 1 year ago

midirhee12 commented 1 year ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

Steps to Reproduce

  1. Declare search engines using programs.firefox.profiles.<name>.search.engines options.
  2. Install search engine extension (even if installed by programs.firefox.profiles.<name>.extensions).
  3. Try to use search engine extension.

Note: this still breaks even if you installed the search engine extensions through home-manager using ``

Actual behavior

Only the search engines defined using the programs.firefox.profiles.<name>.search.engines options work correctly.

Expected behavior

Both the search engines installed via extensions and the home-manager option should work as normal.

Maintainer CC

@kira-bruneau

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.1.31, NixOS, 23.05 (Stoat), 23.05.20230711.8163a64`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `"nixos-23.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
kira-bruneau commented 1 year ago

Hmm, there's not really a good way of working around this since both will use the same file for configuring search engines, and Firefox doesn't offer some kind of config layering for search engines.

Most of the time in home manager you loose out on imperative configuration if you opt for a declarative configuration. I'd recommend porting those extension search engines to the declarative configuration if you want both.

I'll also try to see if there's some way we can merge the config from extensions defined in programs.firefox.profiles.<name>.extensions, but that would likely require IFDs.

midirhee12 commented 1 year ago

Okay, I'm actually finding some seemingly non-deterministic behavior. I somehow managed to get some search extensions to work after a few restarts of firefox and running home-manager a few more times. I'm trying to investigate further, but I'm really clueless as to why.

I think I should also note that I'm using search.force for my configuration.

I'm wondering if this is a problem with how firefox determines what search engines it has instead of an actual home-manager issue.

kira-bruneau commented 1 year ago

Oh, so sometimes Firefox will override the file and that can occur between home-manager activations, but the next time home-manager is activated, it will be reverted to the declarative configuration.

midirhee12 commented 1 year ago

I don't think it's much of "reverting" per se. When the seach extensions do finally start working, the declarative configurations of the search engine still work as well. It's some how reading from both.

Note: I have no experience with imperatively installing search extensions. These are extensions installed from home-manager itself.

kira-bruneau commented 1 year ago

Oh, but that would still make sense. Firefox would imperatively merge the configuration generated by home-manager with the extension configuration.

So when Firefox overrides the configuration, it would keep the declarative options, but when home-manager gets activated it would revert back to the declarative configuration.

midirhee12 commented 1 year ago

Yes, but, if I remember correctly, what also happens is that home-manager stops being able to manage firefox after firefox makes imperative changes such as installing extensions on its own.

kira-bruneau commented 1 year ago

If you're using the force option for the search engines then home-manager is going to forcibly replace the file rather than complain about the file already existing.

kira-bruneau commented 1 year ago

I feel like this is all pretty confusing because of the way Firefox handles search configuration. In your case the extensions are installed declaratively, but Firefox imports the search configuration from those extensions imperatively 🫠

midirhee12 commented 1 year ago

Okay, new update. Some of the one's I've set are getting removed randomly, ie - wikipedia (en) set to alias "w" just got removed today.

stale[bot] commented 10 months 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.