mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-05 00:21:04 +01:00
firefox: migrate search config to v12
This commit is contained in:
parent
b44d79a5b2
commit
8b629b5424
8 changed files with 176 additions and 33 deletions
|
|
@ -12,11 +12,8 @@ let
|
|||
"name"
|
||||
"isAppProvided"
|
||||
"loadPath"
|
||||
"hasPreferredIcon"
|
||||
"updateInterval"
|
||||
"updateURL"
|
||||
"iconUpdateURL"
|
||||
"iconURL"
|
||||
"iconMapObj"
|
||||
"metaData"
|
||||
"orderHint"
|
||||
|
|
@ -26,25 +23,27 @@ let
|
|||
searchForm = "__searchForm";
|
||||
};
|
||||
|
||||
# Convenience to specify absolute path to icon
|
||||
iconUrl = icon:
|
||||
if isPath icon || hasPrefix "/" icon then "file://${icon}" else icon;
|
||||
|
||||
processCustomEngineInput = input:
|
||||
{
|
||||
name = input.id;
|
||||
} // (removeAttrs input [ "icon" ]) // optionalAttrs (input ? icon) {
|
||||
# Convenience to specify absolute path to icon
|
||||
iconURL = "file://${input.icon}";
|
||||
} // (optionalAttrs (input ? iconUpdateURL) {
|
||||
# Convenience to default iconURL to iconUpdateURL so
|
||||
# the icon is immediately downloaded from the URL
|
||||
iconURL = input.iconURL or input.iconUpdateURL;
|
||||
} // (removeAttrs input [ "icon" ])
|
||||
// optionalAttrs (input ? icon || input ? iconMapObj) {
|
||||
iconMapObj = mapAttrs (name: iconUrl) ((optionalAttrs (input ? icon) {
|
||||
# Convenience to specify single icon instead of map
|
||||
"16" = input.icon;
|
||||
}) // (input.iconMapObj or { }));
|
||||
} // {
|
||||
# Required for custom engine configurations, loadPaths
|
||||
# are unique identifiers that are generally formatted
|
||||
# like: [source]/path/to/engine.xml
|
||||
loadPath = "[home-manager]/${
|
||||
concatStringsSep "." (map strings.escapeNixIdentifier
|
||||
(modulePath ++ [ "engines" input.id ]))
|
||||
lib.showAttrPath (modulePath ++ [ "engines" input.id ])
|
||||
}";
|
||||
});
|
||||
};
|
||||
|
||||
processEngineInput = id: input:
|
||||
let
|
||||
|
|
@ -59,6 +58,7 @@ let
|
|||
else
|
||||
pipe (input // requiredInput) [
|
||||
migrateEngineToV11
|
||||
migrateEngineToV12
|
||||
processCustomEngineInput
|
||||
];
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ let
|
|||
};
|
||||
|
||||
settings = {
|
||||
version = 11;
|
||||
version = 12;
|
||||
engines = sortEngineConfigs (mapAttrs buildEngineConfig engineInput);
|
||||
|
||||
metaData = optionalAttrs (config.default != null) {
|
||||
|
|
@ -343,6 +343,21 @@ let
|
|||
inherit value;
|
||||
}) engine.iconMapObj;
|
||||
};
|
||||
|
||||
migrateEngineToV12 = engine:
|
||||
let
|
||||
iconMapObj = optionalAttrs (engine ? iconURL) {
|
||||
"16" = warn "'iconURL' is deprecated, use 'icon = ${
|
||||
strings.escapeNixString engine.iconURL
|
||||
}' instead" engine.iconURL;
|
||||
} // optionalAttrs (engine ? iconUpdateURL) {
|
||||
"16" = warn "'iconUpdateURL' is deprecated, use 'icon = ${
|
||||
strings.escapeNixString engine.iconUpdateURL
|
||||
}' instead" engine.iconUpdateURL;
|
||||
} // (engine.iconMapObj or { });
|
||||
in throwIf (engine ? hasPreferredIcon) "hasPreferredIcon has been removed"
|
||||
(removeAttrs engine [ "iconURL" "iconUpdateURL" ])
|
||||
// lib.optionalAttrs (iconMapObj != { }) { inherit iconMapObj; };
|
||||
in {
|
||||
imports = [ (pkgs.path + "/nixos/modules/misc/meta.nix") ];
|
||||
|
||||
|
|
@ -430,9 +445,8 @@ in {
|
|||
|
||||
nixos-wiki = {
|
||||
name = "NixOS Wiki";
|
||||
urls = [{ template = "https://wiki.nixos.org/index.php?search={searchTerms}"; }];
|
||||
iconUpdateURL = "https://wiki.nixos.org/favicon.png";
|
||||
updateInterval = 24 * 60 * 60 * 1000; # every day
|
||||
urls = [{ template = "https://wiki.nixos.org/w/index.php?search={searchTerms}"; }];
|
||||
iconMapObj."16" = "https://wiki.nixos.org/favicon.ico";
|
||||
definedAliases = [ "@nw" ];
|
||||
};
|
||||
|
||||
|
|
@ -446,7 +460,7 @@ in {
|
|||
only have {var}`metaData` specified will be treated as builtin
|
||||
to ${appName}.
|
||||
|
||||
See [SearchEngine.jsm](https://searchfox.org/mozilla-central/rev/669329e284f8e8e2bb28090617192ca9b4ef3380/toolkit/components/search/SearchEngine.jsm#1138-1177)
|
||||
See [SearchEngine.jsm](https://searchfox.org/mozilla-central/rev/e3f42ec9320748b2aab3d474d1e47075def9000c/toolkit/components/search/SearchEngine.sys.mjs#890-923)
|
||||
in ${appName}'s source for available options. We maintain a
|
||||
mapping to let you specify all options in the referenced link
|
||||
without underscores, but it may fall out of date with future
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue