refacor: firefox search engine settings
This commit is contained in:
parent
33df89b381
commit
298aa410eb
1 changed files with 24 additions and 7 deletions
|
@ -29,19 +29,36 @@ in
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
setSearchEngines = mkEnableOption "firefox search engines";
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.firefox;
|
||||||
|
example = pkgs.firefox-esr;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home-manager.users.moritz.programs.firefox = {
|
home-manager.users.moritz.programs.firefox = {
|
||||||
enable = true;
|
enable = true;
|
||||||
policies = mkIf cfg.setSearchEngines {
|
policies =
|
||||||
SearchEngines = {
|
let
|
||||||
|
removeExtensions = [ "Google" "Amazon.de" "Bing" "Amazon" "Wikipedia (en)" "Wikipedia (de)" ];
|
||||||
|
convertName = name:
|
||||||
|
let
|
||||||
|
lower = toLower name;
|
||||||
|
escaped = replaceStrings [ "." ] [ "dot" ] lower;
|
||||||
|
sanitized = head (splitString " " escaped);
|
||||||
|
in
|
||||||
|
"${sanitized}@search.mozilla.org";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
SearchEngines = mkIf (hasInfix "esr" cfg.package) {
|
||||||
Default = "Kagi";
|
Default = "Kagi";
|
||||||
Remove = [ "Google" "Amazon.de" "Bing" ];
|
Remove = removeExtensions;
|
||||||
};
|
};
|
||||||
|
ExtensionSettings = genAttrs
|
||||||
|
(map convertName removeExtensions)
|
||||||
|
(_: { installation_mode = "blocked"; });
|
||||||
};
|
};
|
||||||
package = if cfg.setSearchEngines then pkgs.firefox-esr else pkgs.firefox;
|
|
||||||
profiles."default" = {
|
profiles."default" = {
|
||||||
extraConfig = mkIf cfg.arkenfox.enable ''
|
extraConfig = mkIf cfg.arkenfox.enable ''
|
||||||
// Arkenfox user.js
|
// Arkenfox user.js
|
||||||
|
|
Loading…
Reference in a new issue