dotfiles/modules/home/graphical/firefox.nix

210 lines
7.5 KiB
Nix
Raw Normal View History

{ pkgs, config, lib, osConfig, self, ... }:
let
cfg = config.my.graphical.firefox;
in {
options.my.graphical.firefox = {
enable = lib.mkEnableOption null;
};
config = let
firefox = pkgs.firefox.override {
extraPolicies = {
DisableFirefoxStudies = true;
DisablePocket = true;
DisableFirefoxAccounts = true;
DisableProfileImport = true;
DisplayBookmarksToolbar = "never";
DownloadDirectory = "\${home}/Downloads/firefox";
NoDefaultBookmarks = true;
OfferToSaveLogins = false;
DontCheckDefaultBrowser = true;
UserMessaging = {
ExtensionRecommendations = false;
SkipOnboarding = true;
};
ExtensionSettings = let
mozillaExtensions = {
buster-captcha-solver = "{e58d3966-3d76-4cd9-8552-1582fbc800c1}";
clearurls = "{74145f27-f039-47ce-a470-a662b129930a}";
search_by_image = "{2e5ff8c8-32fe-46d0-9fc8-6b8986621f3c}";
styl-us = "{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}";
traduzir-paginas-web = "{036a55b4-5e72-4d05-a06c-cba2dfcc134a}";
violentmonkey = "{aecec67f-0d10-4fa7-b7c7-609a2db280cf}";
indie-wiki-buddy = "{cb31ec5d-c49a-4e5a-b240-16c767444f62}";
sponsorblock = "sponsorBlocker@ajay.app";
ublock-origin = "uBlock0@raymondhill.net";
firefox-color = "FirefoxColor@mozilla.com";
foxyproxy-standard = "foxyproxy@eric.h.jung";
} // lib.optionalAttrs config.my.keepassxc.enable {
keepassxc-browser = "keepassxc-browser@keepassxc.org";
};
in builtins.mapAttrs (_: url: {
install_url = url;
installation_mode = "force_installed";
}) (lib.mapAttrs' (name: id:
lib.nameValuePair id "https://addons.mozilla.org/firefox/downloads/latest/${name}/latest.xpi"
) mozillaExtensions);
};
};
in lib.mkIf cfg.enable {
home.packages = let
sandboxed = pkgs.mkNixPak {
config = { sloth, ... }: {
app.package = firefox;
etc.sslCertificates.enable = true;
fonts = {
enable = true;
fonts = osConfig.fonts.packages;
};
gpu.enable = true;
locale.enable = true;
# https://github.com/netblue30/firejail/tree/master/etc/profile-a-l/firefox*.profile
dbus.policies = {
"org.mozilla.*" = "own";
"org.mpris.MediaPlayer2.firefox.*" = "own";
"org.freedesktop.DBus" = "talk";
"org.freedesktop.DBus.*" = "talk";
"org.freedesktop.Notifications" = "talk";
"org.freedesktop.ScreenSaver" = "talk";
"org.freedesktop.portal.*" = "talk";
"org.freedesktop.NetworkManager" = "talk";
"org.freedesktop.FileManager1" = "talk";
};
bubblewrap = {
network = true;
sockets = {
wayland = true;
pulse = true;
};
bind.rw = [
(sloth.concat' sloth.xdgCacheHome "/fontconfig")
(sloth.concat' sloth.homeDir "/.mozilla")
(sloth.concat' sloth.runtimeDir "/bus")
(sloth.concat' sloth.runtimeDir "/dconf")
(sloth.concat' sloth.runtimeDir "/doc")
(sloth.mkdir (sloth.concat' sloth.xdgDownloadDir "/firefox"))
] ++ lib.optionals config.my.keepassxc.enable [
(sloth.concat' sloth.runtimeDir "/app/org.keepassxc.KeePassXC")
];
bind.ro = [
"/etc/localtime"
(sloth.concat' sloth.xdgConfigHome "/gtk-2.0")
(sloth.concat' sloth.xdgConfigHome "/gtk-3.0")
(sloth.concat' sloth.xdgConfigHome "/gtk-4.0")
(sloth.concat' sloth.xdgConfigHome "/dconf")
["${firefox}/lib/firefox" "/app/etc/firefox"]
];
env = let
cursorPackage = config.home.pointerCursor.package;
iconPackage = config.gtk.iconTheme.package;
gtkPackage = config.gtk.theme.package;
in {
XDG_DATA_DIRS = lib.makeSearchPath "share" [
pkgs.shared-mime-info
cursorPackage
iconPackage
gtkPackage
];
XCURSOR_PATH = lib.concatStringsSep ":" [
"${cursorPackage}/share/icons"
"${cursorPackage}/share/pixmaps"
];
};
};
};
};
in lib.singleton sandboxed.config.env;
programs.firefox = {
enable = true;
package = null;
profiles.errie = {
settings = {
"browser.aboutConfig.showWarning" = false;
"browser.cache.disk.enable" = false;
"browser.cache.memory.capacity" = 2000000;
"browser.ctrlTab.sortByRecentlyUsed" = false;
"browser.newtabpage.activity-stream.feeds.section.topstories" = false;
"browser.newtabpage.activity-stream.feeds.topsites" = false;
"browser.newtabpage.pinned" = [];
"browser.startup.page" = 3;
"cookiebanners.service.mode" = 1;
"cookiebanners.service.mode.privateBrowsing" = 1;
"devtools.selfxss.count" = 100;
"media.ffmpeg.vaapi.enabled" = true;
"privacy.webrtc.legacyGlobalIndicator" = false;
"sidebar.main.tools" = "history,bookmarks";
"sidebar.revamp" = true;
"sidebar.verticalTabs" = true;
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
"ui.key.menuAccessKeyFocuses" = false;
};
search = {
default = "DuckDuckGo";
force = true;
order = [ "DuckDuckGo" "SearXNG" "Google" ];
engines = {
"SearXNG" = {
definedAliases = [ "@searxng" ];
icon = "${self}/assets/searxng.svg";
urls = [{
template = "https://etsi.me/search";
params = [{
name = "q";
value = "{searchTerms}";
}];
}];
};
"Nix Packages" = {
definedAliases = [ "@pkgs" "@nixpkgs" ];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "channel";
value = "unstable";
}
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}];
};
"Hoogle" = {
definedAliases = [ "@hoogle" ];
urls = [{
template = "https://hoogle.haskell.org/";
params = [{
name = "hoogle";
value = "{searchTerms}";
}];
}];
};
} // lib.genAttrs [ "Bing" "Amazon.com" "eBay" ] (_: {metaData.hidden = true;});
};
userChrome = ''
/* Hide the close button */
.titlebar-buttonbox-container,
.titlebar-spacer[type="post-tabs"]
{
display: none !important;
}
/* Remove padding on the right */
#nav-bar {
--uc-navbar-padding: 0;
}
'';
};
};
};
}