firefox: support setting search engines
With this change, it's now possible to configure the default search engine in Firefox with programs.firefox.profiles.<name>.search.default and add custom engines with programs.firefox.profiles.<name>.search.engines. It's also recommended to enable programs.firefox.profiles.<name>.search.force = true since Firefox will replace the symlink for the search configuration on every launch, but note that you'll loose any existing configuration by enabling this.
This commit is contained in:
parent
c485669ca5
commit
69d19b9839
4 changed files with 348 additions and 1 deletions
|
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
"engines": [
|
||||
{
|
||||
"_definedAliases": [
|
||||
"@np"
|
||||
],
|
||||
"_iconURL": "file:///run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg",
|
||||
"_isAppProvided": false,
|
||||
"_loadPath": "[home-manager]/programs.firefox.profiles.search.search.engines.\"Nix Packages\"",
|
||||
"_metaData": {
|
||||
"order": 1
|
||||
},
|
||||
"_name": "Nix Packages",
|
||||
"_urls": [
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"name": "type",
|
||||
"value": "packages"
|
||||
},
|
||||
{
|
||||
"name": "query",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
],
|
||||
"template": "https://search.nixos.org/packages"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_definedAliases": [
|
||||
"@nw"
|
||||
],
|
||||
"_iconURL": "https://nixos.wiki/favicon.png",
|
||||
"_iconUpdateURL": "https://nixos.wiki/favicon.png",
|
||||
"_isAppProvided": false,
|
||||
"_loadPath": "[home-manager]/programs.firefox.profiles.search.search.engines.\"NixOS Wiki\"",
|
||||
"_metaData": {
|
||||
"order": 2
|
||||
},
|
||||
"_name": "NixOS Wiki",
|
||||
"_updateInterval": 86400000,
|
||||
"_urls": [
|
||||
{
|
||||
"template": "https://nixos.wiki/index.php?search={searchTerms}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_isAppProvided": true,
|
||||
"_metaData": {
|
||||
"hidden": true
|
||||
},
|
||||
"_name": "Bing"
|
||||
},
|
||||
{
|
||||
"_isAppProvided": true,
|
||||
"_metaData": {},
|
||||
"_name": "DuckDuckGo"
|
||||
},
|
||||
{
|
||||
"_isAppProvided": true,
|
||||
"_metaData": {
|
||||
"alias": "@g"
|
||||
},
|
||||
"_name": "Google"
|
||||
}
|
||||
],
|
||||
"metaData": {
|
||||
"current": "DuckDuckGo",
|
||||
"hash": "BWvqUiaCuMJ20lbymFf2dqzWyl1cgm1LZhhdWNEp0Cc=",
|
||||
"useSavedOrder": true
|
||||
},
|
||||
"version": 6
|
||||
}
|
||||
|
|
@ -60,6 +60,49 @@ lib.mkIf config.test.enableBig {
|
|||
}
|
||||
];
|
||||
};
|
||||
|
||||
profiles.search = {
|
||||
id = 3;
|
||||
search = {
|
||||
force = true;
|
||||
default = "DuckDuckGo";
|
||||
order = [ "Nix Packages" "NixOS Wiki" ];
|
||||
engines = {
|
||||
"Nix Packages" = {
|
||||
urls = [{
|
||||
template = "https://search.nixos.org/packages";
|
||||
params = [
|
||||
{
|
||||
name = "type";
|
||||
value = "packages";
|
||||
}
|
||||
{
|
||||
name = "query";
|
||||
value = "{searchTerms}";
|
||||
}
|
||||
];
|
||||
}];
|
||||
|
||||
icon =
|
||||
"/run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
|
||||
|
||||
definedAliases = [ "@np" ];
|
||||
};
|
||||
|
||||
"NixOS Wiki" = {
|
||||
urls = [{
|
||||
template = "https://nixos.wiki/index.php?search={searchTerms}";
|
||||
}];
|
||||
iconUpdateURL = "https://nixos.wiki/favicon.png";
|
||||
updateInterval = 24 * 60 * 60 * 1000;
|
||||
definedAliases = [ "@nw" ];
|
||||
};
|
||||
|
||||
"Bing".metaData.hidden = true;
|
||||
"Google".metaData.alias = "@g";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
|
|
@ -101,5 +144,15 @@ lib.mkIf config.test.enableBig {
|
|||
assertFileContent \
|
||||
$bookmarksFile \
|
||||
${./profile-settings-expected-bookmarks.html}
|
||||
|
||||
compressedSearch=$(normalizeStorePaths \
|
||||
home-files/.mozilla/firefox/search/search.json.mozlz4)
|
||||
|
||||
decompressedSearch=$(dirname $compressedSearch)/search.json
|
||||
${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch")
|
||||
|
||||
assertFileContent \
|
||||
$decompressedSearch \
|
||||
${./profile-settings-expected-search.json}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue