firefox: fix search options without a default engine
This commit is contained in:
parent
c7c69ec405
commit
564b82b354
|
@ -653,15 +653,21 @@ in {
|
|||
+ "from outside of ${appName} is a malicious act, and will be responded "
|
||||
+ "to accordingly.";
|
||||
|
||||
salt = profile.path + profile.search.default
|
||||
+ disclaimer "Firefox";
|
||||
salt = if profile.search.default != null then
|
||||
profile.path + profile.search.default + disclaimer "Firefox"
|
||||
else
|
||||
null;
|
||||
in pkgs.runCommand "search.json.mozlz4" {
|
||||
nativeBuildInputs = with pkgs; [ mozlz4a openssl ];
|
||||
json = builtins.toJSON settings;
|
||||
inherit salt;
|
||||
} ''
|
||||
export hash=$(echo -n "$salt" | openssl dgst -sha256 -binary | base64)
|
||||
mozlz4a <(substituteStream json search.json.in --subst-var hash) "$out"
|
||||
if [[ -n $salt ]]; then
|
||||
export hash=$(echo -n "$salt" | openssl dgst -sha256 -binary | base64)
|
||||
mozlz4a <(substituteStream json search.json.in --subst-var hash) "$out"
|
||||
else
|
||||
mozlz4a <(echo "$json") "$out"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"engines": [
|
||||
{
|
||||
"_isAppProvided": true,
|
||||
"_metaData": {
|
||||
"order": 1
|
||||
},
|
||||
"_name": "Google"
|
||||
},
|
||||
{
|
||||
"_definedAliases": [
|
||||
"@np"
|
||||
],
|
||||
"_isAppProvided": false,
|
||||
"_loadPath": "[home-manager]/programs.firefox.profiles.searchWithoutDefault.search.engines.\"Nix Packages\"",
|
||||
"_metaData": {
|
||||
"order": 2
|
||||
},
|
||||
"_name": "Nix Packages",
|
||||
"_urls": [
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"name": "type",
|
||||
"value": "packages"
|
||||
},
|
||||
{
|
||||
"name": "query",
|
||||
"value": "{searchTerms}"
|
||||
}
|
||||
],
|
||||
"template": "https://search.nixos.org/packages"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"metaData": {
|
||||
"useSavedOrder": true
|
||||
},
|
||||
"version": 6
|
||||
}
|
|
@ -109,6 +109,33 @@ lib.mkIf config.test.enableBig {
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
profiles.searchWithoutDefault = {
|
||||
id = 4;
|
||||
search = {
|
||||
force = true;
|
||||
order = [ "Google" "Nix Packages" ];
|
||||
engines = {
|
||||
"Nix Packages" = {
|
||||
urls = [{
|
||||
template = "https://search.nixos.org/packages";
|
||||
params = [
|
||||
{
|
||||
name = "type";
|
||||
value = "packages";
|
||||
}
|
||||
{
|
||||
name = "query";
|
||||
value = "{searchTerms}";
|
||||
}
|
||||
];
|
||||
}];
|
||||
|
||||
definedAliases = [ "@np" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
|
@ -151,14 +178,23 @@ lib.mkIf config.test.enableBig {
|
|||
$bookmarksFile \
|
||||
${./profile-settings-expected-bookmarks.html}
|
||||
|
||||
compressedSearch=$(normalizeStorePaths \
|
||||
home-files/.mozilla/firefox/search/search.json.mozlz4)
|
||||
function assertFirefoxSearchContent() {
|
||||
compressedSearch=$(normalizeStorePaths "$1")
|
||||
|
||||
decompressedSearch=$(dirname $compressedSearch)/search.json
|
||||
${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch")
|
||||
decompressedSearch=$(dirname $compressedSearch)/search.json
|
||||
${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch")
|
||||
|
||||
assertFileContent \
|
||||
$decompressedSearch \
|
||||
assertFileContent \
|
||||
$decompressedSearch \
|
||||
"$2"
|
||||
}
|
||||
|
||||
assertFirefoxSearchContent \
|
||||
home-files/.mozilla/firefox/search/search.json.mozlz4 \
|
||||
${./profile-settings-expected-search.json}
|
||||
|
||||
assertFirefoxSearchContent \
|
||||
home-files/.mozilla/firefox/searchWithoutDefault/search.json.mozlz4 \
|
||||
${./profile-settings-expected-search-without-default.json}
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue