mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 20:09:07 +01:00
firefox: Refactor extension configuration
This commit is contained in:
parent
8131f054b5
commit
ed4c27a901
1 changed files with 74 additions and 25 deletions
|
|
@ -5,10 +5,72 @@
|
|||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.custom.programs.firefox.enable = lib.mkEnableOption "";
|
||||
let
|
||||
cfg = config.custom.programs.firefox;
|
||||
|
||||
mkExtension =
|
||||
{
|
||||
name,
|
||||
uuid,
|
||||
defaultArea,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = uuid;
|
||||
value = {
|
||||
install_url = "file:///${
|
||||
inputs.firefox-addons.packages.${pkgs.stdenv.hostPlatform.system}.${name}
|
||||
}/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/${uuid}.xpi";
|
||||
installation_mode = "force_installed";
|
||||
default_area = defaultArea;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.custom.programs.firefox = {
|
||||
enable = lib.mkEnableOption "";
|
||||
extensions = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
enable = lib.mkEnableOption "" // {
|
||||
default = true;
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = name;
|
||||
};
|
||||
uuid = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
defaultArea = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"menupanel"
|
||||
"navbar"
|
||||
];
|
||||
default = "menupanel";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
custom.programs.firefox.extensions = {
|
||||
dictionary-german.uuid = "de-DE@dictionaries.addons.mozilla.org";
|
||||
ublock-origin.uuid = "uBlock0@raymondhill.net";
|
||||
bitwarden.uuid = "{446900e4-71c2-419f-a6a7-df9c091e268b}";
|
||||
return-youtube-dislikes.uuid = "{762f9885-5a13-4abd-9c77-433dcd38b8fd}";
|
||||
sponsorblock.uuid = "sponsorBlocker@ajay.app";
|
||||
clearurls.uuid = "{74145f27-f039-47ce-a470-a662b129930a}";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.custom.programs.firefox.enable {
|
||||
programs.firefox = {
|
||||
enable = true;
|
||||
|
||||
|
|
@ -40,29 +102,16 @@
|
|||
};
|
||||
|
||||
policies.ExtensionSettings =
|
||||
let
|
||||
extension = shortId: uuid: {
|
||||
name = uuid;
|
||||
value = {
|
||||
install_url = "file:///${
|
||||
inputs.firefox-addons.packages.${pkgs.stdenv.hostPlatform.system}.${shortId}
|
||||
}/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/${uuid}.xpi";
|
||||
installation_mode = "force_installed";
|
||||
default_area = "menupanel";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
(
|
||||
cfg.extensions
|
||||
|> lib.attrValues
|
||||
|> lib.filter ({ enable, ... }: enable)
|
||||
|> lib.map mkExtension
|
||||
|> lib.listToAttrs
|
||||
)
|
||||
// {
|
||||
"*".installation_mode = "blocked";
|
||||
}
|
||||
// lib.listToAttrs [
|
||||
(extension "dictionary-german" "de-DE@dictionaries.addons.mozilla.org")
|
||||
(extension "ublock-origin" "uBlock0@raymondhill.net")
|
||||
(extension "bitwarden" "{446900e4-71c2-419f-a6a7-df9c091e268b}")
|
||||
(extension "return-youtube-dislikes" "{762f9885-5a13-4abd-9c77-433dcd38b8fd}")
|
||||
(extension "sponsorblock" "sponsorBlocker@ajay.app")
|
||||
(extension "clearurls" "{74145f27-f039-47ce-a470-a662b129930a}")
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue