home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

librewolf: use mkFirefoxModule

Open chayleaf opened this issue 1 year ago • 13 comments

Description

Checklist

  • [x] Change is backwards compatible.

  • [x] Code formatted with ./format.

  • [ ] Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • [ ] Test cases updated/added. See example.

  • [x] Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • [ ] Added myself as module maintainer. See example.

Maintainer CC

@onny

chayleaf avatar Jul 29 '24 10:07 chayleaf

Bookmarks don't appear to work, so they should probably be turned off somehow.

  programs.librewolf.profiles.default.bookmarks = [{
    name = "bookmarklets";
    toolbar = true;
    bookmarks = [
      {
        name = "example.com";
        url = "https://example.com";
      }
    ];
  }];

I vaguely recall someone mentioning this somewhere.

tomodachi94 avatar Jul 31 '24 20:07 tomodachi94

Yea I had shared the same experience with bookmarks in https://github.com/nix-community/home-manager/pull/5128#issue-2182871606, but removed it in a later edit of the message.

The option could be marked as internal to hide it from generated documentation and to discourage users from using it. Alternatively the readOnly option could be used with an empty default.

brckd avatar Aug 02 '24 14:08 brckd

Looks great otherwise!

brckd avatar Aug 02 '24 15:08 brckd

why does it not work though? it doesn't look like librewolf patches out any bookmark-related code

chayleaf avatar Aug 03 '24 19:08 chayleaf

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/librewolf-kde-integration-not-working/50464/6

nixos-discourse avatar Aug 13 '24 23:08 nixos-discourse

How would this implement nativeMessagingHosts and how could i use this for that when this gets merged?

SpiderUnderUrBed avatar Aug 24 '24 22:08 SpiderUnderUrBed

It's implemented in the underlying mkFirefoxModule. https://github.com/nix-community/home-manager/blob/master/modules/programs/firefox/mkFirefoxModule.nix#L39-L49

https://github.com/nix-community/home-manager/blob/master/modules/programs/firefox/mkFirefoxModule.nix#L830-L834

Custom native messaging hosts can be added using programs.librewolf.nativeMessagingHosts.

brckd avatar Aug 25 '24 06:08 brckd

Is it normal for the tests to take this long? It seems to me like they have said "Waiting for status to be reported" since the beginning of last month.

Anomalocaridid avatar Oct 13 '24 22:10 Anomalocaridid

Hey @chayleaf, in case you aren't busy, could you take a look at my latest review? This way we would give the tests a rerun.

brckd avatar Oct 14 '24 06:10 brckd

These tests sure take long. Perhaps they haven't started yet because of GitHub limits?

brckd avatar Oct 15 '24 10:10 brckd

I don't think these tests are going to finish anytime soon, is there something wrong with them? Or is there any possibility of running them locally if that will help.

SpiderUnderUrBed avatar Oct 15 '24 10:10 SpiderUnderUrBed

The tests won't run until the workflow is approved.

donovanglover avatar Oct 15 '24 20:10 donovanglover

I tried this PR and got an error:

home-manager-path> error: collision between `/nix/store/r4af2fhjq0m7sz20fx6apbdj61wzd7yg-librewolf-131.0.2-1/lib/librewolf/distribution/policies.json' and `/nix/store/9fbmav58r0mxlqwrxglz7lwzm3733c6g-librewolf-131.0.2-1/lib/librewolf/distribution/policies.json'

(the only difference of the two files is that one has {"policies": {"DefaultDownloadDirectory": "/tmp"}} set and the other has not)

I limited my librewolf config to

programs.librewolf = {
  enable = true;
  policies.DefaultDownloadDirectory = "/tmp";
};

which still reproduced the error, this noticeably does not fail when replacing librewolf with firefox in this minimal example.

A workaround is:

programs.librewolf = {
  enable = true;
  package = pkgs.librewolf.override (old: {
    extraPolicies = (old.extraPolicies or { }) // {DefaultDownloadDirectory = "/tmp";};
  });
};

or even

programs.librewolf = {
  enable = true;
  package = pkgs.librewolf.override (old: {
    extraPolicies = (old.extraPolicies or { }) // config.programs.librewolf.policies;
  });
  policies.DefaultDownloadDirectory = "/tmp";
};

I also noticed a similar behavior with nativeMessagingHosts, it has no effect applied to programs.librewolf but works fine when applied to programs.librewolf.package = pkgs.librewolf.override (...).

all using github:NixOS/nixpkgs/c4c95cac8161486a52f901a27ccdb5f8e80380b1

TilCreator avatar Oct 18 '24 23:10 TilCreator

Is it possible to declare different profiles using mkFirefoxModule? (by profiles i am referring to about:profiles)

SpiderUnderUrBed avatar Nov 03 '24 23:11 SpiderUnderUrBed

If you mean multiple profiles in librewolf you can replace firefox with librewolf in the docs and it will work

donovanglover avatar Nov 04 '24 16:11 donovanglover

I cannot set custom search engine entries as default. This is the relevant snippet in my Home Manager configuration:

search = {
  force = true;
  engines = {
    "Startpage" = {
      urls = [{ template = "https://www.startpage.com/do/dsearch?q={searchTerms}"; }];
      iconUpdateURL = "https://www.startpage.com/sp/cdn/favicons/favicon--default.ico";
      updateInterval = 24 * 60 * 60 * 1000; # every day
    };

    "Bing".metaData.hidden = true;
    "DuckDuckGo".metaData.hidden = true;
    "Google".metaData.hidden = true;
  };
  default = "Startpage";
  privateDefault = "Startpage";
  order = [ "Startpage" ];
};

The default search engine is still Google, although it should be hidden. Startpage is the first entry in the drop-down menu under "Default Search Engine" in Librewolf's search settings, so I think it should be available. This exact configuration in the Firefox Home Manager module gives the expected results that Startpage is the default search engine.

I then tried to set an existing search engine as the default:

search = {
  force = true;
  engines = {
    "Bing".metaData.hidden = true;
    "Google".metaData.hidden = true;
  };
  default = "DuckDuckGo";
  privateDefault = "DuckDuckGo";
  order = [ "DuckDuckGo" ];
};

This works as expected. DuckDuckGo is the default search engine and Bing and Google are hidden.

sid115 avatar Nov 09 '24 14:11 sid115

@sid115 I think that is addressed by #5685

Anomalocaridid avatar Nov 09 '24 16:11 Anomalocaridid

~~I have a similar issue to https://github.com/nix-community/home-manager/pull/5684#issuecomment-2423372447, but over the presence of "ExtensionSettings":{} in the policies file instead. Reverting #5840 fixed it, but I suspect that the fundamental issue is that it's even trying to include two librewolfs in the path in the first place.~~

EDIT: has been fixed as of https://github.com/nix-community/home-manager/pull/5684#event-15336083531.

MithicSpirit avatar Nov 16 '24 21:11 MithicSpirit

Could someone please approve the test workflow again? This has been sitting for a few weeks waiting for the tests to be re-run.

Anomalocaridid avatar Nov 16 '24 23:11 Anomalocaridid

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-configure-multiple-packages-using-single-home-manager-module/54587/7

nixos-discourse avatar Nov 17 '24 02:11 nixos-discourse

Thanks! Merged to master now 🙂

rycee avatar Nov 18 '24 21:11 rycee

Is it expected to get this feature (backported) in release-24.11? Would be really awesome to have this in the new release

TilCreator avatar Nov 19 '24 11:11 TilCreator

So after working with the Librewolf configuration for a while, it seems to be working well for me with the one exception of nativeMessagingHosts (I'm using tridactyl-native and ff2mpv-rust). As @TilCreator mentions above, after moving the config into a package override, Librewolf does then interact with these packages.

  programs.librewolf = {
    enable = true;

    package = pkgs.librewolf.override {
      nativeMessagingHosts = with pkgs; [
        # Convert Firefox URLs to MPV runs
        ff2mpv-rust

        # Native messenger for tridactyl to enable all the features.
        # You can confirm it's found by FF by running `:native`.
        tridactyl-native
      ];
    };

    policies = (import ./policies.nix { });

    profiles.johnhamelink = (
      import ./profiles/johnhamelink.nix {
        inherit (pkgs) nixos-icons;
        inherit (pkgs.nur.repos.rycee) firefox-addons;
        inherit (lib) licenses platforms;
        inherit buildFirefoxXpiAddon;
      }
    );
  };

Another - perhaps obvious - thing to mention is that Librewolf will not inherit the history and tab state of Firefox when you switch over. I naively thought that Librewolf would be configured to pull its configuration from the same place and just inherit the state, but this doesn't seem to be the case. However after reinstalling FF, I was able to recover the state and export it for Librewolf without issue. This is also my first time using Librewolf, I thought I'd mention in case others are in the same boat.

johnhamelink avatar Nov 19 '24 17:11 johnhamelink