{ lib, config, pkgs, inputs, ... }: with lib; with lib.custom; let cfg = config.apps.web.librewolf; natsumi = pkgs.fetchFromGitHub { owner = "greeeen-dev"; repo = "natsumi-browser"; rev = "1300fd5751f4b366b0c8ec668e99ce55b1593d7b"; hash = "sha256-08oflxcLAYoQV4O4JeWhG4JRIYcNROKdbEDNSxzK4JU="; }; in { options.apps.web.librewolf = with types; { enable = mkBoolOpt false "Enable or disable librewolf"; setDefault = mkBoolOpt false "Set Librewolf as default browser"; }; config = mkIf cfg.enable { xdg.mimeApps.defaultApplications = mkIf cfg.setDefault { "text/html" = "librewolf.desktop"; "x-scheme-handler/http" = "librewolf.desktop"; "x-scheme-handler/https" = "librewolf.desktop"; }; home.file.".librewolf/${config.home.username}/chrome" = { source = "${natsumi}"; recursive = true; }; programs.librewolf = { enable = true; profiles.default = lib.mkForce { id = 1; isDefault = false; extensions = { force = true; }; }; profiles.${config.home.username} = { id = 0; isDefault = true; extensions = { force = true; }; settings = { "toolkit.legacyUserProfileCustomizations.stylesheets" = true; "sidebar.verticalTabs" = true; "webgl.disabled" = false; "privacy.resistFingerprinting" = false; "privacy.clearOnShutdown.history" = false; "privacy.clearOnShutdown.cookies" = false; "network.cookie.lifetimePolicy" = 0; "natsumi.theme.type" = "default"; }; search = { default = "SearXNG"; engines = { "NixOS Options" = { urls = [ { template = "https://search.nixos.org/options?query={searchTerms}"; } ]; icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; definedAliases = ["@nixos"]; }; "Nix Packages" = { urls = [ { template = "https://search.nixos.org/packages?query={searchTerms}"; } ]; icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; definedAliases = ["@nixpkgs"]; }; "OpenStreetMap" = { urls = [ { template = "https://www.openstreetmap.org/search?query={searchTerms}"; } ]; icon = "https://www.openstreetmap.org/favicon.ico"; definedAliases = [ "@openstreetmap" "@osm" ]; }; "SearXNG" = { urls = [ { template = "https://search.zoeys.computer/searx/search?q={searchTerms}"; } ]; icon = "https://search.zoeys.computer/searx/static/themes/simple/img/favicon.svg"; definedAliases = ["@searx"]; }; "docs.rs" = { urls = [ { template = "https://docs.rs/releases/search?query={searchTerms}"; } ]; icon = "https://docs.rs/-/static/favicon.ico"; definedAliases = ["@docs"]; }; "crates.io" = { urls = [ { template = "https://crates.io/search?q={searchTerms}"; } ]; icon = "https://crates.io/assets/cargo.png"; definedAliases = ["@crates"]; }; }; force = true; # Required to prevent search engine symlink being overwritten. See https://github.com/nix-community/home-manager/issues/3698 }; }; policies = { ExtensionSettings = with builtins; let extension = shortId: uuid: { name = uuid; value = { install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; installation_mode = "normal_installed"; }; }; in listToAttrs [ (extension "ublock-origin" "uBlock0@raymondhill.net") (extension "privacy-badger17" "jid1-MnnxcxisBPnSXQ@jetpack") (extension "1password-x-password-manager" "{d634138d-c276-4fc8-924b-40a0ea21d284}") (extension "styl-us" "{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}") (extension "betterttv" "firefox@betterttv.net") (extension "decentraleyes" "jid1-BoFifL9Vbdl2zQ@jetpack") (extension "canvasblocker" "CanvasBlocker@kkapsner.de") (extension "clearurls" "{74145f27-f039-47ce-a470-a662b129930a}") ]; }; }; }; }