declarative firefox config with home-manager on nixos

declarative firefox config with home-manager on nixos

As a man who finds himself reinstalling his OS more than is probably sensible, any opportunity to minimise the post install admin of sorting out all your settings is an attractive one. With that in mind lets take a look at some of the firefox (my current browser of choice) configuration options avilable to you through home-manager. This assumes you have some sort of home-manager setup working. If you do not I found this friendly githubber’s templates to be very helpful.

First of all you’ll need to enable firefox with programs.firefox.enable = true;

EXTENSIONS

This will require having the NUR (nix user repo) enabled. But once you do, you can configure any extension you want to be auto installed with something like this:

{pkgs, ... }:
  let
    addons = pkgs.nur.repos.rycee.firefox-addons;
  in
  {
    programs.firefox = {
      extensions = with addons; [
        ublock-origin
        bitwarden
        darkreader
      ];
    };
  }

This is the list of all extensions available in the repo.

BOOKMARKS

Bookmarks can be added per profile. The format for it goes something like this:

profiles.james = {
  bookmarks = [
    {
	  name = "best website ever!";
      url = "https://jdysmcl.xyz";
    }
    {
	  name = "best OS ever";
      url = "https://nixos.org";
    }
  ];
};

SETTINGS

Again, these can be added per profile. Basically, any option you can find in about:config can be added here; this is a selection of potentially useful options I have set:

profiles.james = {
  settings = {
    #newtab stuff
    "browser.startup.homepage" = "https://searx.jdysmcl.xyz";
    "browser.newtabpage.enabled" = false;
    "browser.newtabpage.activity-stream.enabled" = false;

    #some firefox features i don't really want
    "extensions.pocket.enabled" = false;
    "extensions.formautofill.creditCards.enabled" = false;
    "identity.fxaccounts.enabled" = false;
    "signon.rememberSignons" = false;
    "browser.search.suggest.enabled" = false;

    #some privacy stuff
    "privacy.resistFingerprinting" = true;
    "privacy.trackingprotection.enabled" = true;
    "dom.security.https_only_mode" = true;
  };
};

Of course I am sure there are many more exciting things that could be done here but this is as far as I have got. For all avilable options you can check out this or alternatively run a man home-configuration.nix. Hope this has been helpful :)