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

librewolf: use mkFirefoxModule #5684

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chayleaf
Copy link

Description

Checklist

  • Change is backwards compatible.

  • 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.

  • 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

Benjamin-L added a commit to Benjamin-L/home-manager that referenced this pull request Jul 31, 2024
@tomodachi94
Copy link
Contributor

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 added a commit to tomodachi94/dotfiles that referenced this pull request Jul 31, 2024
This is temporary until mkFirefoxModule is added to the
programs.librewolf module:
nix-community/home-manager#5684
tomodachi94 added a commit to tomodachi94/dotfiles that referenced this pull request Jul 31, 2024
This is temporary until mkFirefoxModule is added to the
programs.librewolf module:
nix-community/home-manager#5684
@brckd
Copy link
Contributor

brckd commented Aug 2, 2024

Yea I had shared the same experience with bookmarks in #5128 (comment), 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
Copy link
Contributor

brckd commented Aug 2, 2024

Looks great otherwise!

@chayleaf
Copy link
Author

chayleaf commented Aug 3, 2024

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

Copy link
Contributor

@donovanglover donovanglover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see this finally be a feature. From my initial testing everything works as expected.

For anyone else trying this out, the default search engine won't change in v128 unless you patch #5685 in your fork as well.

@nixos-discourse
Copy link

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

name = "LibreWolf";
wrappedPackageName = "librewolf";
unwrappedPackageName = "librewolf-unwrapped";
visible = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
visible = true;

I would probably unset visible, because otherwise it makes the generic Firefox options appear twice in the generated documentation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems fine to me, that's how it works in nixpkgs, are the home-manager docs conventions different?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about the conventions, but that's how the chromite module does it. It also hides generic options for its derivatives.

imports = [
(mkFirefoxModule {
inherit modulePath;
name = "LibreWolf";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "LibreWolf";
name = "LibreWolf";
description = "LibreWolf is a privacy enhanced Firefox fork.";

Optionally include the original description.

@SpiderUnderUrBed
Copy link

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

@brckd
Copy link
Contributor

brckd commented Aug 25, 2024

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.

Copy link
Contributor

@MithicSpirit MithicSpirit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been using this and #5685 for a couple of days now, and it's been working very well.

@Anomalocaridid
Copy link
Contributor

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.

@brckd
Copy link
Contributor

brckd commented Oct 14, 2024

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
Copy link
Contributor

brckd commented Oct 15, 2024

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

@SpiderUnderUrBed
Copy link

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.

@donovanglover
Copy link
Contributor

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

@TilCreator
Copy link

TilCreator commented Oct 18, 2024

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

@SpiderUnderUrBed
Copy link

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

@donovanglover
Copy link
Contributor

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

@sid115
Copy link

sid115 commented Nov 9, 2024

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.

@Anomalocaridid
Copy link
Contributor

Anomalocaridid commented Nov 9, 2024

@sid115 I think that is addressed by #5685

@MithicSpirit
Copy link
Contributor

I have a similar issue to #5684 (comment), 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.

@Anomalocaridid
Copy link
Contributor

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

@nixos-discourse
Copy link

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

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

Successfully merging this pull request may close these issues.

10 participants