summaryrefslogtreecommitdiff
path: root/modules/home-manager/personal/programs/firefox/default.nix
blob: 46aaca15f790178da31a146badd2fd2f82a6b9f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
  config,
  lib,
  pkgs,
  ...
}:
with lib;
let
  userjs = pkgs.callPackage ./userjs.nix {
    inherit (pkgs.personal.static.userjs) arkenfox;
    inherit (pkgs.lib.personal) toUserJS;
  };
  engines = import ./engines.nix { inherit lib pkgs; };
in
{
  config = lib.mkMerge [
    {
      stylix.targets.firefox = {
        colorTheme.enable = true;
        profileNames = [
          "default"
        ];
      };
      programs.firefox = {
        configPath = "${config.xdg.configHome}/mozilla/firefox";
        profiles.default = {
          id = 0; # isDefault = true
          extensions = {
            packages = with pkgs.personal.firefoxAddons; [
              canvasblocker
              clearurls
              darkreader
              neat-url
              redirector
              smart-referer
              temporary-containers
              ublock-origin
              unpaywall
              url-in-title
            ];
            settings."FirefoxColor@mozilla.com" = {
              force = true;
              settings.theme.colors =
                let
                  mkBgColor = lib.mkForce (
                    with config.lib.stylix.colors;
                    {
                      r = base00-rgb-r;
                      g = base00-rgb-g;
                      b = base00-rgb-b;
                    }
                  );
                in
                {
                  frame = mkBgColor;
                  sidebar_border = mkBgColor;
                  popup_border = mkBgColor;
                  tab_baground_separator = mkBgColor;
                  tab_line = mkBgColor;
                  toolbar_field_border_focus = mkBgColor;
                };
            };
          };
          search = {
            force = lib.mkDefault true;
            engines =
              with engines;
              disableDefault
              // {
                inherit Searx;
              }
              // lib.optionalAttrs config.personal.identities.personal personal
              // lib.optionalAttrs config.personal.identities.work work
              // lib.optionalAttrs config.personal.profiles.dev dev;
            default = "Searx";
            order = [
              "Searx"
              "Wikipedia"
            ];
          };
          extraConfig = userjs.default;
        };

      };
    }

    (lib.mkIf config.programs.firefox.enable {
      home.shellAliases.fftmp = "firefox --profile $(mktemp -d)";
      home.sessionVariables.BROWSER = "firefox";
    })
  ];
}