1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00

firefox: migrate search config to v12

This commit is contained in:
Kira Bruneau 2025-03-18 17:00:40 -04:00 committed by Austin Horstman
parent b44d79a5b2
commit 8b629b5424
8 changed files with 176 additions and 33 deletions

View file

@ -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

View file

@ -55,10 +55,10 @@ in {
urls = [{
template =
"https://wiki.nixos.org/index.php?search={searchTerms}";
"https://wiki.nixos.org/w/index.php?search={searchTerms}";
}];
iconUpdateURL = "https://wiki.nixos.org/favicon.png";
updateInterval = 24 * 60 * 60 * 1000;
iconMapObj."16" = "https://wiki.nixos.org/favicon.ico";
definedAliases = [ "@nw" ];
};
@ -163,6 +163,36 @@ in {
};
};
};
migrateIconsV12 = {
id = 4;
search = {
force = true;
engines = {
nix-packages = {
name = "Nix Packages";
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}];
iconURL = "https://search.nixos.org/favicon.ico";
iconUpdateURL = "https://search.nixos.org/favicon.ico";
definedAliases = [ "@np" ];
};
};
};
};
};
} // {
nmt.script = let
@ -212,6 +242,10 @@ in {
assertFirefoxSearchContent \
home-files/${cfg.configPath}/migrateIconsV11/search.json.mozlz4 \
${withName ./expected-migrate-icons-v11.json}
assertFirefoxSearchContent \
home-files/${cfg.configPath}/migrateIconsV12/search.json.mozlz4 \
${withName ./expected-migrate-icons-v12.json}
'';
});
}

View file

@ -22,5 +22,5 @@
"metaData": {
"useSavedOrder": false
},
"version": 11
"version": 12
}

View file

@ -0,0 +1,36 @@
{
"engines": [
{
"_definedAliases": [
"@np"
],
"_iconMapObj": {
"16": "https://search.nixos.org/favicon.ico"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.@name@.profiles.migrateIconsV12.search.engines.nix-packages",
"_metaData": {},
"_name": "Nix Packages",
"_urls": [
{
"params": [
{
"name": "type",
"value": "packages"
},
{
"name": "query",
"value": "{searchTerms}"
}
],
"template": "https://search.nixos.org/packages"
}
],
"id": "nix-packages"
}
],
"metaData": {
"useSavedOrder": false
},
"version": 12
}

View file

@ -0,0 +1,54 @@
{
"engines": [
{
"_definedAliases": [
"@np"
],
"_iconMapObj": {
"16": "https://search.nixos.org/favicon.ico"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.@name@.profiles.migrateIcons.search.engines.nix-packages",
"_metaData": {},
"_name": "Nix Packages",
"_urls": [
{
"params": [
{
"name": "type",
"value": "packages"
},
{
"name": "query",
"value": "{searchTerms}"
}
],
"template": "https://search.nixos.org/packages"
}
],
"id": "nix-packages"
},
{
"_definedAliases": [
"@nw"
],
"_iconMapObj": {
"16": "https://wiki.nixos.org/favicon.ico"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.@name@.profiles.migrateIcons.search.engines.nixos-wiki",
"_metaData": {},
"_name": "NixOS Wiki",
"_urls": [
{
"template": "https://wiki.nixos.org/w/index.php?search={searchTerms}"
}
],
"id": "nixos-wiki"
}
],
"metaData": {
"useSavedOrder": false
},
"version": 12
}

View file

@ -4,7 +4,9 @@
"_definedAliases": [
"@np"
],
"_iconURL": "file:///run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg",
"_iconMapObj": {
"16": "file:///run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.librewolf.profiles.migrateSearchV7.search.engines.\"Nix Packages\"",
"_metaData": {
@ -32,8 +34,9 @@
"_definedAliases": [
"@nw"
],
"_iconURL": "https://wiki.nixos.org/favicon.ico",
"_iconUpdateURL": "https://wiki.nixos.org/favicon.ico",
"_iconMapObj": {
"16": "https://wiki.nixos.org/favicon.ico"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.librewolf.profiles.migrateSearchV7.search.engines.\"NixOS Wiki\"",
"_metaData": {
@ -75,5 +78,5 @@
"privateDefaultEngineIdHash": "@privateHash@",
"useSavedOrder": true
},
"version": 11
"version": 12
}

View file

@ -38,5 +38,5 @@
"metaData": {
"useSavedOrder": true
},
"version": 11
"version": 12
}

View file

@ -4,7 +4,9 @@
"_definedAliases": [
"@np"
],
"_iconURL": "file:///run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg",
"_iconMapObj": {
"16": "file:///run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.@name@.profiles.search.search.engines.nix-packages",
"_metaData": {
@ -32,18 +34,18 @@
"_definedAliases": [
"@nw"
],
"_iconURL": "https://wiki.nixos.org/favicon.png",
"_iconUpdateURL": "https://wiki.nixos.org/favicon.png",
"_iconMapObj": {
"16": "https://wiki.nixos.org/favicon.ico"
},
"_isAppProvided": false,
"_loadPath": "[home-manager]/programs.@name@.profiles.search.search.engines.nixos-wiki",
"_metaData": {
"order": 2
},
"_name": "NixOS Wiki",
"_updateInterval": 86400000,
"_urls": [
{
"template": "https://wiki.nixos.org/index.php?search={searchTerms}"
"template": "https://wiki.nixos.org/w/index.php?search={searchTerms}"
}
],
"id": "nixos-wiki"
@ -75,5 +77,5 @@
"privateDefaultEngineIdHash": "@privateHash@",
"useSavedOrder": true
},
"version": 11
"version": 12
}