mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 03:09:47 +01:00
firefox: fix search options without a default engine
This commit is contained in:
parent
c7c69ec405
commit
564b82b354
3 changed files with 93 additions and 10 deletions
|
@ -653,15 +653,21 @@ in {
|
||||||
+ "from outside of ${appName} is a malicious act, and will be responded "
|
+ "from outside of ${appName} is a malicious act, and will be responded "
|
||||||
+ "to accordingly.";
|
+ "to accordingly.";
|
||||||
|
|
||||||
salt = profile.path + profile.search.default
|
salt = if profile.search.default != null then
|
||||||
+ disclaimer "Firefox";
|
profile.path + profile.search.default + disclaimer "Firefox"
|
||||||
|
else
|
||||||
|
null;
|
||||||
in pkgs.runCommand "search.json.mozlz4" {
|
in pkgs.runCommand "search.json.mozlz4" {
|
||||||
nativeBuildInputs = with pkgs; [ mozlz4a openssl ];
|
nativeBuildInputs = with pkgs; [ mozlz4a openssl ];
|
||||||
json = builtins.toJSON settings;
|
json = builtins.toJSON settings;
|
||||||
inherit salt;
|
inherit salt;
|
||||||
} ''
|
} ''
|
||||||
|
if [[ -n $salt ]]; then
|
||||||
export hash=$(echo -n "$salt" | openssl dgst -sha256 -binary | base64)
|
export hash=$(echo -n "$salt" | openssl dgst -sha256 -binary | base64)
|
||||||
mozlz4a <(substituteStream json search.json.in --subst-var hash) "$out"
|
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 = [
|
nixpkgs.overlays = [
|
||||||
|
@ -151,14 +178,23 @@ lib.mkIf config.test.enableBig {
|
||||||
$bookmarksFile \
|
$bookmarksFile \
|
||||||
${./profile-settings-expected-bookmarks.html}
|
${./profile-settings-expected-bookmarks.html}
|
||||||
|
|
||||||
compressedSearch=$(normalizeStorePaths \
|
function assertFirefoxSearchContent() {
|
||||||
home-files/.mozilla/firefox/search/search.json.mozlz4)
|
compressedSearch=$(normalizeStorePaths "$1")
|
||||||
|
|
||||||
decompressedSearch=$(dirname $compressedSearch)/search.json
|
decompressedSearch=$(dirname $compressedSearch)/search.json
|
||||||
${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch")
|
${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch")
|
||||||
|
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
$decompressedSearch \
|
$decompressedSearch \
|
||||||
|
"$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
assertFirefoxSearchContent \
|
||||||
|
home-files/.mozilla/firefox/search/search.json.mozlz4 \
|
||||||
${./profile-settings-expected-search.json}
|
${./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