1{
2 pkgs,
3 lib,
4 config,
5 ...
6}: let
7 engines = import ./engines.nix;
8in {
9 options.mySnippets.firefox-based = {
10 policies = lib.mkOption {
11 type = lib.types.attrs;
12 description = "Policies for Firefox-based browsers";
13 default = {
14 Cookies.Behavior = "reject-foreign";
15 DisableAppUpdate = true;
16 DisableFirefoxStudies = true;
17 DisableMasterPasswordCreation = true;
18 DisablePocket = true;
19 DisableProfileImport = true;
20 DisableSetDesktopBackground = true;
21 DisableTelemetry = true;
22 DisplayBookmarksToolbar = "newtab";
23 #DisableFirefoxAccounts = true;
24 DisableSafeMode = true;
25
26 AutofillAddressEnabled = false;
27 AutofillCreditCardEnabled = false;
28
29 HttpsOnlyMode = "enabled";
30
31 DNSOverHTTPS = {
32 Enabled = true;
33 Fallback = true;
34 };
35
36 DontCheckDefaultBrowser = true;
37
38 EnableTrackingProtection = {
39 Cryptomining = true;
40 Fingerprinting = true;
41 EmailTracking = true;
42 Locked = false;
43 Value = true;
44 };
45
46 EncryptedMediaExtensions = {
47 Enabled = true;
48 Locked = false;
49 };
50
51 FirefoxHome = {
52 Highlights = false;
53 Locked = false;
54 Pocket = false;
55 Search = true;
56 Snippets = false;
57 SponsoredPocket = false;
58 SponsoredTopSites = false;
59 TopSites = false;
60 };
61
62 FirefoxSuggest = {
63 ImproveSuggest = false;
64 Locked = false;
65 SponsoredSuggestions = false;
66 WebSuggestions = false;
67 };
68
69 HardwareAcceleration = true;
70
71 Homepage = {
72 Locked = false;
73 StartPage = "previous-session";
74 };
75
76 NewTabPage = false;
77 NoDefaultBookmarks = true; # Enabling this prevents declaratively setting bookmarks.
78 OfferToSaveLoginsDefault = false;
79 OverrideFirstRunPage = "";
80 OverridePostUpdatePage = "";
81
82 PDFjs = {
83 Enabled = true;
84 EnablePermissions = false;
85 };
86
87 Preferences = {
88 # Do not add the extra "Import Bookmarks" button in the bookmarks interface
89 "browser.bookmarks.addedImportButton" = false;
90
91 # Mark that the user has accepted the data reporting (telemetry) policy
92 "datareporting.policy.dataSubmissionPolicyAccepted" = false;
93
94 # Allow extensions from all scopes (profile, system, etc.) without auto-disabling them
95 "extensions.autoDisableScopes" = 0;
96
97 # Enable VA-API hardware video decoding via FFmpeg (useful on Linux systems)
98 "media.ffmpeg.vaapi.enabled" = true;
99
100 # Enable the VP8/VP9 media data decoder, used in WebRTC and video playback
101 "media.navigator.mediadatadecoder_vpx_enabled" = true;
102
103 # Enable the Remote Data Decoder (RDD) process for FFmpeg to isolate media decoding tasks
104 "media.rdd-ffmpeg.enabled" = true;
105
106 # Use the XDG Desktop Portal for file picker instead of the GTK3 one
107 widget.use-xdg-desktop-portal.file-picker = 1;
108 };
109
110 UserMessaging = {
111 ExtensionRecommendations = false;
112 FeatureRecommendations = false;
113 MoreFromMozilla = false;
114 SkipOnboarding = true;
115 };
116
117 UseSystemPrintDialog = true;
118 };
119 };
120
121 userConfig = lib.mkOption {
122 type = lib.types.attrs;
123 description = "My config for Firefox-based browsers";
124 default = {
125 enable = true;
126
127 inherit (config.mySnippets.firefox-based) policies;
128
129 #nativeMessagingHosts = lib.optionals pkgs.stdenv.isLinux [pkgs.bitwarden-desktop];
130 languagePacks = [
131 "en-CA"
132 "en"
133 "en-US"
134 ];
135
136 # this for some reason doesn't work neither here nor in /modules/nixos/programs/firefox, but i'm keeping it here so i can remember to install those manually again if i ever need to
137 # policies = {
138 # ExtensionSettings = {
139 # "magnolia@12.34" = {
140 # default_area = "menupanel";
141 # install_url = "https://gitflic.ru/project/magnolia1234/bpc_uploads/blob/raw?file=bypass_paywalls_cle# an-latest.xpi";
142 # installation_mode = "normal_installed";
143 # };
144 # "pt-BR@dictionaries.addons.mozilla.org" = {
145 # install_url = "https://addons.mozilla.org/firefox/downloads/latest/corretor/latest.xpi";
146 # installation_mode = "normal_installed";
147 # };
148 # };
149 # };
150
151 profiles = {
152 default = {
153 id = 0;
154 isDefault = true;
155
156 extensions.packages = with pkgs.nur.repos.rycee.firefox-addons; [
157 consent-o-matic
158 ublock-origin
159 aria2-integration
160 #keepassxc-browser
161 libredirect
162 stylus
163 violentmonkey
164 ublacklist
165 steam-database
166 snowflake
167 sponsorblock
168 #karakeep
169 bitwarden
170 ];
171
172 search = {
173 inherit engines;
174 default = "Unduck";
175 force = true;
176
177 order = [
178 "Unduck"
179 "Brave"
180 "Home Manager Options"
181 "NixOS Wiki"
182 "nixpkgs"
183 "wikipedia"
184 "Wiktionary"
185 ];
186 };
187
188 settings =
189 (import ./betterfox/fastfox.nix)
190 // (import ./betterfox/peskyfox.nix)
191 // (import ./betterfox/securefox.nix)
192 // (import ./betterfox/smoothfox.nix)
193 // {
194 "browser.tabs.groups.enabled" = true;
195 "browser.tabs.groups.smart.enabled" = true;
196 "svg.context-properties.content.enabled" = true;
197 "general.autoScroll" = true;
198 "ui.key.menuAccessKeyFocuses" = false;
199 "browser.search.separatePrivateDefault" = false;
200 "media.videocontrols.picture-in-picture.video-toggle.enabled" = false;
201 "browser.ml.chat.sidebar" = false;
202 };
203
204 userContent = ''
205 @font-face {
206 font-family: "Segoe UI";
207 src: url("${pkgs.roboto-flex}/share/fonts/truetype/RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].ttf");
208 }
209 @font-face {
210 font-family: "system-ui";
211 src: url("${pkgs.roboto-flex}/share/fonts/truetype/RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].ttf");
212 }
213 @font-face {
214 font-family: "-apple-system";
215 src: url("${pkgs.roboto-flex}/share/fonts/truetype/RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].ttf");
216 }
217 @font-face {
218 font-family: "BlinkMacSystemFont";
219 src: url("${pkgs.roboto-flex}/share/fonts/truetype/RobotoFlex[GRAD,XOPQ,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght].ttf");
220 }
221 '';
222 };
223 };
224 };
225 };
226 };
227}