mirror of
https://github.com/nix-community/home-manager
synced 2024-11-14 07:09: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
dfb56a4a77
commit
68f5ac390c
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 {
|
order = mkOption {
|
||||||
type = with types; uniq (listOf str);
|
type = with types; uniq (listOf str);
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
@ -675,8 +684,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
"${profilesPath}/${profile.path}/search.json.mozlz4" = mkIf
|
"${profilesPath}/${profile.path}/search.json.mozlz4" = mkIf
|
||||||
(profile.search.default != null || profile.search.order != [ ]
|
(profile.search.default != null || profile.search.privateDefault != null
|
||||||
|| profile.search.engines != { }) {
|
|| profile.search.order != [ ] || profile.search.engines != { }) {
|
||||||
force = profile.search.force;
|
force = profile.search.force;
|
||||||
source = let
|
source = let
|
||||||
settings = {
|
settings = {
|
||||||
|
@ -767,12 +776,18 @@ in {
|
||||||
# engine if it's not in profile.search.engines
|
# engine if it's not in profile.search.engines
|
||||||
${profile.search.default} =
|
${profile.search.default} =
|
||||||
profile.search.engines.${profile.search.default} or { };
|
profile.search.engines.${profile.search.default} or { };
|
||||||
|
} // {
|
||||||
|
${profile.search.privateDefault} =
|
||||||
|
profile.search.engines.${profile.search.privateDefault} or { };
|
||||||
};
|
};
|
||||||
in sortEngineConfigs (mapAttrs buildEngineConfig engineInput);
|
in sortEngineConfigs (mapAttrs buildEngineConfig engineInput);
|
||||||
|
|
||||||
metaData = optionalAttrs (profile.search.default != null) {
|
metaData = optionalAttrs (profile.search.default != null) {
|
||||||
current = profile.search.default;
|
current = profile.search.default;
|
||||||
hash = "@hash@";
|
hash = "@hash@";
|
||||||
|
} // optionalAttrs (profile.search.privateDefault != null) {
|
||||||
|
private = profile.search.privateDefault;
|
||||||
|
privateHash = "@privateHash@";
|
||||||
} // {
|
} // {
|
||||||
useSavedOrder = profile.search.order != [ ];
|
useSavedOrder = profile.search.order != [ ];
|
||||||
};
|
};
|
||||||
|
@ -794,14 +809,21 @@ in {
|
||||||
profile.path + profile.search.default + disclaimer "Firefox"
|
profile.path + profile.search.default + disclaimer "Firefox"
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
privateSalt = if profile.search.privateDefault != null then
|
||||||
|
profile.path + profile.search.privateDefault
|
||||||
|
+ 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 privateSalt;
|
||||||
} ''
|
} ''
|
||||||
if [[ -n $salt ]]; then
|
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"
|
export privateHash=$(echo -n "$privateSalt" | openssl dgst -sha256 -binary | base64)
|
||||||
|
mozlz4a <(substituteStream json search.json.in --subst-var hash --subst-var privateHash) "$out"
|
||||||
else
|
else
|
||||||
mozlz4a <(echo "$json") "$out"
|
mozlz4a <(echo "$json") "$out"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -67,8 +67,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metaData": {
|
"metaData": {
|
||||||
"current": "DuckDuckGo",
|
"current": "Google",
|
||||||
"hash": "BWvqUiaCuMJ20lbymFf2dqzWyl1cgm1LZhhdWNEp0Cc=",
|
"hash": "IRmKVSQlAYnvLO8kdZyNUR/g5hzVn4++T0PLPGm+kZk=",
|
||||||
|
"private": "DuckDuckGo",
|
||||||
|
"privateHash": "BWvqUiaCuMJ20lbymFf2dqzWyl1cgm1LZhhdWNEp0Cc=",
|
||||||
"useSavedOrder": true
|
"useSavedOrder": true
|
||||||
},
|
},
|
||||||
"version": 6
|
"version": 6
|
||||||
|
|
|
@ -75,7 +75,8 @@
|
||||||
id = 3;
|
id = 3;
|
||||||
search = {
|
search = {
|
||||||
force = true;
|
force = true;
|
||||||
default = "DuckDuckGo";
|
default = "Google";
|
||||||
|
privateDefault = "DuckDuckGo";
|
||||||
order = [ "Nix Packages" "NixOS Wiki" ];
|
order = [ "Nix Packages" "NixOS Wiki" ];
|
||||||
engines = {
|
engines = {
|
||||||
"Nix Packages" = {
|
"Nix Packages" = {
|
||||||
|
|
Loading…
Reference in a new issue