2021-02-04 08:46:16 +09:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.targets.darwin;
|
|
|
|
searchEngines = {
|
|
|
|
Bing = "com.bing.www";
|
|
|
|
DuckDuckGo = "com.duckduckgo";
|
|
|
|
Ecosia = "org.ecosia.www";
|
|
|
|
Google = "com.google.www";
|
|
|
|
Yahoo = "com.yahoo.www";
|
|
|
|
};
|
2025-03-07 14:16:46 -06:00
|
|
|
searchId = lib.getAttr cfg.search searchEngines;
|
2021-02-04 08:46:16 +09:00
|
|
|
in {
|
2025-03-07 14:16:46 -06:00
|
|
|
options.targets.darwin.search = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr (enum (lib.attrNames searchEngines));
|
2021-02-04 08:46:16 +09:00
|
|
|
default = null;
|
|
|
|
description = "Default search engine.";
|
|
|
|
};
|
|
|
|
|
2025-03-07 14:16:46 -06:00
|
|
|
config = lib.mkIf (cfg.search != null) {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
2025-03-07 14:16:46 -06:00
|
|
|
(lib.hm.assertions.assertPlatform "targets.darwin.search" pkgs
|
|
|
|
lib.platforms.darwin)
|
2021-07-07 23:24:27 +02:00
|
|
|
];
|
|
|
|
|
2021-02-04 08:46:16 +09:00
|
|
|
targets.darwin.defaults = {
|
|
|
|
NSGlobalDomain.NSPreferredWebServices = {
|
|
|
|
NSWebServicesProviderWebSearch = {
|
|
|
|
NSDefaultDisplayName = cfg.search;
|
|
|
|
NSProviderIdentifier = searchId;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
"com.apple.Safari".SearchProviderIdentifier = searchId;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|