mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
firefox: support setting a separate default search engine in private browsing (#4114)
* firefox: support setting a separate default search engine in private browing Ref: https://searchfox.org/mozilla-central/rev/05d1afda588e54be73e31ef4e022dde91f1ed97a/toolkit/components/search/SearchSettings.sys.mjs#548 * Update modules/programs/firefox.nix --------- Co-authored-by: Naïm Favier <n@monade.li>
This commit is contained in:
parent
50e582b9f9
commit
280721186a
3 changed files with 32 additions and 7 deletions
|
@ -444,6 +444,15 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
privateDefault = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
example = "DuckDuckGo";
|
||||
description = ''
|
||||
The default search engine used in the Private Browsing.
|
||||
'';
|
||||
};
|
||||
|
||||
order = mkOption {
|
||||
type = with types; uniq (listOf str);
|
||||
default = [ ];
|
||||
|
@ -675,8 +684,8 @@ in {
|
|||
};
|
||||
|
||||
"${profilesPath}/${profile.path}/search.json.mozlz4" = mkIf
|
||||
(profile.search.default != null || profile.search.order != [ ]
|
||||
|| profile.search.engines != { }) {
|
||||
(profile.search.default != null || profile.search.privateDefault != null
|
||||
|| profile.search.order != [ ] || profile.search.engines != { }) {
|
||||
force = profile.search.force;
|
||||
source = let
|
||||
settings = {
|
||||
|
@ -767,12 +776,18 @@ in {
|
|||
# engine if it's not in profile.search.engines
|
||||
${profile.search.default} =
|
||||
profile.search.engines.${profile.search.default} or { };
|
||||
} // {
|
||||
${profile.search.privateDefault} =
|
||||
profile.search.engines.${profile.search.privateDefault} or { };
|
||||
};
|
||||
in sortEngineConfigs (mapAttrs buildEngineConfig engineInput);
|
||||
|
||||
metaData = optionalAttrs (profile.search.default != null) {
|
||||
current = profile.search.default;
|
||||
hash = "@hash@";
|
||||
} // optionalAttrs (profile.search.privateDefault != null) {
|
||||
private = profile.search.privateDefault;
|
||||
privateHash = "@privateHash@";
|
||||
} // {
|
||||
useSavedOrder = profile.search.order != [ ];
|
||||
};
|
||||
|
@ -794,14 +809,21 @@ in {
|
|||
profile.path + profile.search.default + disclaimer "Firefox"
|
||||
else
|
||||
null;
|
||||
|
||||
privateSalt = if profile.search.privateDefault != null then
|
||||
profile.path + profile.search.privateDefault
|
||||
+ disclaimer "Firefox"
|
||||
else
|
||||
null;
|
||||
in pkgs.runCommand "search.json.mozlz4" {
|
||||
nativeBuildInputs = with pkgs; [ mozlz4a openssl ];
|
||||
json = builtins.toJSON settings;
|
||||
inherit salt;
|
||||
inherit salt privateSalt;
|
||||
} ''
|
||||
if [[ -n $salt ]]; then
|
||||
export hash=$(echo -n "$salt" | openssl dgst -sha256 -binary | base64)
|
||||
mozlz4a <(substituteStream json search.json.in --subst-var hash) "$out"
|
||||
export privateHash=$(echo -n "$privateSalt" | openssl dgst -sha256 -binary | base64)
|
||||
mozlz4a <(substituteStream json search.json.in --subst-var hash --subst-var privateHash) "$out"
|
||||
else
|
||||
mozlz4a <(echo "$json") "$out"
|
||||
fi
|
||||
|
|
|
@ -67,8 +67,10 @@
|
|||
}
|
||||
],
|
||||
"metaData": {
|
||||
"current": "DuckDuckGo",
|
||||
"hash": "BWvqUiaCuMJ20lbymFf2dqzWyl1cgm1LZhhdWNEp0Cc=",
|
||||
"current": "Google",
|
||||
"hash": "IRmKVSQlAYnvLO8kdZyNUR/g5hzVn4++T0PLPGm+kZk=",
|
||||
"private": "DuckDuckGo",
|
||||
"privateHash": "BWvqUiaCuMJ20lbymFf2dqzWyl1cgm1LZhhdWNEp0Cc=",
|
||||
"useSavedOrder": true
|
||||
},
|
||||
"version": 6
|
||||
|
|
|
@ -75,7 +75,8 @@
|
|||
id = 3;
|
||||
search = {
|
||||
force = true;
|
||||
default = "DuckDuckGo";
|
||||
default = "Google";
|
||||
privateDefault = "DuckDuckGo";
|
||||
order = [ "Nix Packages" "NixOS Wiki" ];
|
||||
engines = {
|
||||
"Nix Packages" = {
|
||||
|
|
Loading…
Reference in a new issue