diff --git a/nix/configurations/vanadium/home/firefox.nix b/nix/configurations/vanadium/home/firefox.nix index a362ee59..69923a91 100644 --- a/nix/configurations/vanadium/home/firefox.nix +++ b/nix/configurations/vanadium/home/firefox.nix @@ -9,12 +9,6 @@ # reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters mkLrFlag = languageRestrictions: "&lr=" + lib.escapeURL (builtins.concatStringsSep "|" languageRestrictions); - - mkGlFlag = preferredCountry: - "&gl=" + preferredCountry; - - mkHlFlag = hostLanguage: - "&hl=" + hostLanguage; in { programs.firefox = { enable = true; @@ -23,91 +17,91 @@ in { RequestedLocales = ["fr" "en-US" "zh-TW"]; SearchEngines = { - Default = "Google Customized"; + Default = "Google EN"; Remove = ["Google"]; Add = let - withGoogleFlags = x: - x - + mkLrFlag ["lang_fr" "lang_en" "lang_zh-TW"] - + mkGlFlag "fr" - + mkHlFlag "fr"; - in [ - # Google and its evil empireā„¢ - { - Name = "Google Customized"; - Alias = "G"; + langs = ["lang_fr" "lang_en" "lang_zh-TW"]; + in + # Google specialized for each language + map (lang: let + shortcode = lib.substring 0 2 (lib.removePrefix "lang_" lang); + in { + Name = "Google " + lib.toUpper shortcode; + Alias = "G" + shortcode; IconURL = "https://google.com/favicon.ico"; - Description = "Your data yum yum"; - SuggestURLTemplate = withGoogleFlags "https://suggestqueries.google.com/complete/search?q={searchTerms}"; - URLTemplate = withGoogleFlags "https://google.com/search?q={searchTerms}"; - } - { - Name = "YouTube"; - Alias = "yt"; - IconURL = "https://youtube.com/favicon.ico"; - SuggestURLTemplate = withGoogleFlags "http://suggestqueries.google.com/complete/search?q={searchTerms}&ds=yt"; - URLTemplate = withGoogleFlags "https://www.youtube.com/results?search_query={searchTerms}"; - } + Description = "Your data yum yum (but ${shortcode})"; + SuggestURLTemplate = "https://suggestqueries.google.com/complete/search?q={searchTerms}" + mkLrFlag [lang]; + URLTemplate = "https://google.com/search?q={searchTerms}" + mkLrFlag [lang]; + }) + langs + ++ [ + { + Name = "YouTube"; + Alias = "yt"; + IconURL = "https://youtube.com/favicon.ico"; + SuggestURLTemplate = "http://suggestqueries.google.com/complete/search?q={searchTerms}&ds=yt"; + URLTemplate = "https://www.youtube.com/results?search_query={searchTerms}"; + } - # Forges - { - Name = "GitHub"; - Alias = "ggh"; - IconURL = "https://github.com/favicon.ico"; - Description = "Your code yum yum"; - URLTemplate = "https://github.com/search?q={searchTerms}&type=repositories"; - } - { - Name = "GitHub (Code Search)"; - Alias = "gghc"; - IconURL = "https://github.com/favicon.ico"; - Description = "Your code yum yum"; - URLTemplate = "https://github.com/search?q={searchTerms}&type=code"; - } - { - Name = "Codeberg"; - Alias = "gco"; - IconURL = "https://codeberg.org/favicon.ico"; - Description = "Software development, but free!"; - URLTemplate = "https://codeberg.org/explore/repos?q={searchTerms}"; - } - { - Name = "?C"; - Alias = "gcc"; - IconURL = "https://git.confusedcompiler.org/favicon.ico"; - URLTemplate = "https://git.confusedcompiler.org/explore/repos?q={searchTerms}"; - } + # Forges + { + Name = "GitHub"; + Alias = "ggh"; + IconURL = "https://github.com/favicon.ico"; + Description = "Your code yum yum"; + URLTemplate = "https://github.com/search?q={searchTerms}&type=repositories"; + } + { + Name = "GitHub (Code Search)"; + Alias = "gghc"; + IconURL = "https://github.com/favicon.ico"; + Description = "Your code yum yum"; + URLTemplate = "https://github.com/search?q={searchTerms}&type=code"; + } + { + Name = "Codeberg"; + Alias = "gco"; + IconURL = "https://codeberg.org/favicon.ico"; + Description = "Software development, but free!"; + URLTemplate = "https://codeberg.org/explore/repos?q={searchTerms}"; + } + { + Name = "?C"; + Alias = "gcc"; + IconURL = "https://git.confusedcompiler.org/favicon.ico"; + URLTemplate = "https://git.confusedcompiler.org/explore/repos?q={searchTerms}"; + } - # Nix{,OS,pkgs} - { - Name = "NixOS Search (Package)"; - Alias = "np"; - IconURL = "https://nixos.org/favicon.ico"; - Description = "Search in nixpkgs"; - URLTemplate = "https://search.nixos.org/packages?query={searchTerms}"; - } - { - Name = "NixOS Search (Options)"; - Alias = "no"; - IconURL = "https://nixos.org/favicon.ico"; - Description = "Search in NixOS options"; - URLTemplate = "https://search.nixos.org/options?query={searchTerms}"; - } + # Nix{,OS,pkgs} + { + Name = "NixOS Search (Package)"; + Alias = "np"; + IconURL = "https://nixos.org/favicon.ico"; + Description = "Search in nixpkgs"; + URLTemplate = "https://search.nixos.org/packages?query={searchTerms}"; + } + { + Name = "NixOS Search (Options)"; + Alias = "no"; + IconURL = "https://nixos.org/favicon.ico"; + Description = "Search in NixOS options"; + URLTemplate = "https://search.nixos.org/options?query={searchTerms}"; + } - # Discourse - { - Name = "NixOS Discourse"; - Alias = "nd"; - IconURL = "https://nixos.org/favicon.ico"; - URLTemplate = "https://discourse.nixos.org/search?q={searchTerms}"; - } - { - Name = "Framework Discourse"; - Alias = "fd"; - IconURL = "https://frame.work/favicon.ico"; - URLTemplate = "https://community.frame.work/search?q={searchTerms}"; - } - ]; + # Discourse + { + Name = "NixOS Discourse"; + Alias = "nd"; + IconURL = "https://nixos.org/favicon.ico"; + URLTemplate = "https://discourse.nixos.org/search?q={searchTerms}"; + } + { + Name = "Framework Discourse"; + Alias = "fd"; + IconURL = "https://frame.work/favicon.ico"; + URLTemplate = "https://community.frame.work/search?q={searchTerms}"; + } + ]; }; };