summaryrefslogtreecommitdiff
path: root/common/programs/zenBrowser.nix
blob: 99f77232670c653303f3c391d156e20bb22f4999 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{
inputs,
pkgs,
lib,
...
}:
let
  extension = shortId: guid: {
    name = guid;
    value = {
      install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi";
      installation_mode = "normal_installed";
      private_browsing = true;
      default_area = "menupanel"; # menupanel = unpin, navbar = pin
    };
  };

  prefs = {
    "browser.aboutConfig.showWarning" = false;
    "browser.sessionstore.resume_from_crash" = false;
    "browser.sessionstore.restore_on_demand" = false;
    "browser.sessionstore.restore_tabs_lazily" = false;
    "browser.sessionstore.restore_windows_to_virtual_desktop" = false;
    "browser.sessionstore.max_resumed_crashes" = 0;
    "gfx.webrender.all" = true;
    "gfx.webrender.compositor" = true;
    "gfx.x11-egl.force-enabled" = true;
    "layers.acceleration.force-enabled" = true;
    "media.ffmpeg.vaapi.enabled" = true;
    "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
    "zen.welcome-screen.seen" = true;
  };

  extensions = [
    (extension "ublock-origin" "uBlock0@raymondhill.net")
    (extension "darkreader" "addon@darkreader.org")
  ];
in
  {
  config = lib.mkIf !config.programs.firefox.enable {
    home.packages = [
      (pkgs.wrapFirefox
        inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.zen-browser-unwrapped
        {
          extraPrefs = lib.concatLines (
            lib.mapAttrsToList (
              name: value: "lockPref(${lib.strings.toJSON name}, ${lib.strings.toJSON value});"
            ) prefs
          );

          extraPolicies = {
            DisableTelemetry = true;
            AutofillAddressEnabled = true;
            AutofillCreditCardEnabled = false;
            DisableAppUpdate = true;
            DisableFeedbackCommands = true;
            DisableFirefoxStudies = true;
            DisablePocket = true;
            DontCheckDefaultBrowser = true;
            NoDefaultBookmarks = true;
            DisableFirefoxScreenshots = true;
            OfferToSaveLogins = false;
            EnableTrackingProtection = {
              Value = true;
              Locked = true;
              Cryptomining = true;
              Fingerprinting = true;
            };
            DNSOverHTTPS = {
              Enabled = true;
              ProviderURL = "https://dns.quad9.net/dns-query";
              Locked = true;
              Fallback = true;
            };

            ExtensionSettings = builtins.listToAttrs extensions;

            SearchEngines = {
              Default = "DuckDuckGo";
              # Default = "Omnisearch";
              PreventInstalls = true;
              Remove = [
                "Google"
                "Bing"
              ];
              Add = [
                # {
                #   Name = "Omnisearch";
                #   URLTemplate = "http://localhost:8087/search?q={searchTerms}";
                #   IconURL = "http://localhost:8087/static/favicon.ico";
                #   Alias = ":o";
                # }
                {
                  Name = "nixpkgs packages";
                  URLTemplate = "https://search.nixos.org/packages?query={searchTerms}";
                  IconURL = "https://wiki.nixos.org/favicon.ico";
                  Alias = ":np";
                }
                {
                  Name = "NixOS options";
                  URLTemplate = "https://search.nixos.org/options?query={searchTerms}";
                  IconURL = "https://wiki.nixos.org/favicon.ico";
                  Alias = ":no";
                }
                {
                  Name = "NixOS Wiki";
                  URLTemplate = "https://wiki.nixos.org/w/index.php?search={searchTerms}";
                  IconURL = "https://wiki.nixos.org/favicon.ico";
                  Alias = ":nw";
                }
                {
                  Name = "noogle";
                  URLTemplate = "https://noogle.dev/q?term={searchTerms}";
                  IconURL = "https://noogle.dev/favicon.ico";
                  Alias = ":ng";
                }
              ];
            };
          };
        }
      )
    ];

    xdg.configFile = {
      "userContent.css" = {
        enable = false;
        text =
          # css
          ''
          img, canvas, video, .avatar, 
          [class*="avatar"], 
          [class*="ProfileAvatar"],
          [style*="border-radius"] {
            border-radius: 0 !important;
            clip-path: none !important;
            mask-image: none !important;
            -webkit-mask-image: none !important;
          }

          /* 2. Reset standard rounding on all elements EXCEPT SVGs */
          :not(svg):not(circle):not(ellipse):not(path) {
            border-radius: 0 !important;
          }

          /* 3. Handle variables that usually affect containers/images */
          :root {
            --border-radius: 0px !important;
            --radius: 0px !important;
            --rounded-corner: 0px !important;
            --avatar-radius: 0px !important;
            --pfp-radius: 0px !important;
          }
          '';
      };
    };
  };
}