mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-18 22:33:00 +00:00
* nixos: remove with lib * nix-darwin: remove with lib * home-manager: remove with lib * modules/accounts: remove with lib * modules/config: remove with lib * modules/i18n: remove with lib * modules/misc: remove with lib * modules: remove with lib * modules/targets: remove with lib * tests/modules/firefox: remove with lib * tests/modules/services: remove with lib
36 lines
965 B
Nix
36 lines
965 B
Nix
{ 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";
|
|
};
|
|
searchId = lib.getAttr cfg.search searchEngines;
|
|
in {
|
|
options.targets.darwin.search = lib.mkOption {
|
|
type = with lib.types; nullOr (enum (lib.attrNames searchEngines));
|
|
default = null;
|
|
description = "Default search engine.";
|
|
};
|
|
|
|
config = lib.mkIf (cfg.search != null) {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "targets.darwin.search" pkgs
|
|
lib.platforms.darwin)
|
|
];
|
|
|
|
targets.darwin.defaults = {
|
|
NSGlobalDomain.NSPreferredWebServices = {
|
|
NSWebServicesProviderWebSearch = {
|
|
NSDefaultDisplayName = cfg.search;
|
|
NSProviderIdentifier = searchId;
|
|
};
|
|
};
|
|
"com.apple.Safari".SearchProviderIdentifier = searchId;
|
|
};
|
|
};
|
|
}
|