browser: fixup firefox forks

This commit is contained in:
DashieTM 2025-05-11 12:53:38 +02:00
parent ea385722b0
commit 2b704cc5e7
4 changed files with 226 additions and 179 deletions

View file

@ -0,0 +1,46 @@
{
lib,
stable,
pkgs,
name,
...
}: let
mkExtension = id: install_url: {
${id} = {
inherit install_url;
installation_mode = "normal_installed";
};
};
in {
options.mods.browser.${name}.extensions = lib.mkOption {
default = [
(mkExtension "uBlock0@raymondhill.net" "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi")
(mkExtension "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" "https://addons.mozilla.org/firefox/downloads/latest/user-agent-string-switcher/latest.xpi")
(mkExtension "{d7742d87-e61d-4b78-b8a1-b469842139fa}" "https://addons.mozilla.org/firefox/downloads/latest/vimium-ff/latest.xpi")
(mkExtension "firefox@ghostery.com" "https://addons.mozilla.org/firefox/downloads/latest/ghostery/latest.xpi")
(mkExtension "CanvasBlocker@kkapsner.de" "https://addons.mozilla.org/firefox/downloads/latest/canvasblocker/latest.xpi")
(mkExtension "jid1-KKzOGWgsW3Ao4Q@jetpack" "https://addons.mozilla.org/firefox/downloads/latest/i-dont-care-about-cookies/latest.xpi")
(mkExtension "keepassxc-browser@keepassxc.org" "https://addons.mozilla.org/firefox/downloads/latest/keepassxc-browser/latest.xpi")
(mkExtension "@react-devtools" "https://addons.mozilla.org/firefox/downloads/latest/react-devtools/latest.xpi")
(mkExtension "extension@redux.devtools" "https://addons.mozilla.org/firefox/downloads/latest/reduxdevtools/latest.xpi")
(mkExtension "private-relay@firefox.com" "https://addons.mozilla.org/firefox/downloads/latest/private-relay/latest.xpi")
(mkExtension "addon@darkreader.org" "file://${pkgs.callPackage ../../../patches/darkreader.nix {inherit lib stable;}}/latest.xpi")
];
example = [];
type = with lib.types; listOf anything;
description = ''
List of extensions via attrsets:
```nix
# id
# figure out the id via:
# nix run github:tupakkatapa/mozid -- 'https://addons.mozilla.org/en/firefox/addon/ublock-origin'
"uBlock0@raymondhill.net" = {
# install url
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
# method https://mozilla.github.io/policy-templates/#extensionsettings
installation_mode = "force_installed";
};
```
'';
};
}

View file

@ -3,9 +3,16 @@
config, config,
options, options,
pkgs, pkgs,
stable,
... ...
}: { }: let
options.mods.browser.firefox = { name = "firefox";
in {
imports = [
(import ./ffextensions.nix
{inherit lib stable pkgs name;})
];
options.mods.browser.${name} = {
enable = lib.mkOption { enable = lib.mkOption {
default = false; default = false;
example = true; example = true;
@ -88,7 +95,17 @@
config.mods.browser.firefox.profiles; config.mods.browser.firefox.profiles;
programs.firefox = { programs.firefox = {
enable = true; enable = true;
policies = config.mods.browser.firefox.configuration; package =
pkgs.wrapFirefox
pkgs.firefox-unwrapped
{
pname = "firefox";
extraPolicies =
config.mods.browser.firefox.configuration
// {
ExtensionSettings = builtins.foldl' (acc: ext: acc // ext) {} config.mods.browser.firefox.extensions;
};
};
profiles = builtins.listToAttrs config.mods.browser.firefox.profiles; profiles = builtins.listToAttrs config.mods.browser.firefox.profiles;
}; };
} }

View file

@ -3,9 +3,16 @@
config, config,
options, options,
pkgs, pkgs,
stable,
... ...
}: { }: let
options.mods.browser.librewolf = { name = "librewolf";
in {
imports = [
(import ./ffextensions.nix
{inherit lib stable pkgs name;})
];
options.mods.browser.${name} = {
enable = lib.mkOption { enable = lib.mkOption {
default = false; default = false;
example = true; example = true;
@ -82,8 +89,17 @@
lib.optionalAttrs (options ? home.packages) { lib.optionalAttrs (options ? home.packages) {
programs.librewolf-dashnix = { programs.librewolf-dashnix = {
enable = true; enable = true;
package = pkgs.librewolf; package =
policies = config.mods.browser.librewolf.configuration; pkgs.wrapFirefox
pkgs.librewolf-unwrapped
{
pname = "librewolf";
extraPolicies =
config.mods.browser.librewolf.configuration
// {
ExtensionSettings = builtins.foldl' (acc: ext: acc // ext) {} config.mods.browser.librewolf.extensions;
};
};
profiles = builtins.listToAttrs config.mods.browser.librewolf.profiles; profiles = builtins.listToAttrs config.mods.browser.librewolf.profiles;
}; };
} }

View file

@ -13,51 +13,19 @@
# hence ensure it is by using base16 mkSchemeAttrs # hence ensure it is by using base16 mkSchemeAttrs
base16 = pkgs.callPackage inputs.base16.lib {}; base16 = pkgs.callPackage inputs.base16.lib {};
scheme = base16.mkSchemeAttrs config.stylix.base16Scheme; scheme = base16.mkSchemeAttrs config.stylix.base16Scheme;
mkExtension = id: install_url: { name = "zen";
${id} = {
inherit install_url;
installation_mode = "normal_installed";
};
};
in { in {
options.mods.browser.zen = { imports = [
(import ./ffextensions.nix
{inherit lib stable pkgs name;})
];
options.mods.browser.${name} = {
enable = lib.mkOption { enable = lib.mkOption {
default = false; default = false;
example = true; example = true;
type = lib.types.bool; type = lib.types.bool;
description = "Enables the zen browser"; description = "Enables the zen browser";
}; };
extensions = lib.mkOption {
default = [
(mkExtension "uBlock0@raymondhill.net" "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi")
(mkExtension "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" "https://addons.mozilla.org/firefox/downloads/latest/user-agent-string-switcher/latest.xpi")
(mkExtension "{d7742d87-e61d-4b78-b8a1-b469842139fa}" "https://addons.mozilla.org/firefox/downloads/latest/vimium-ff/latest.xpi")
(mkExtension "firefox@ghostery.com" "https://addons.mozilla.org/firefox/downloads/latest/ghostery/latest.xpi")
(mkExtension "CanvasBlocker@kkapsner.de" "https://addons.mozilla.org/firefox/downloads/latest/canvasblocker/latest.xpi")
(mkExtension "jid1-KKzOGWgsW3Ao4Q@jetpack" "https://addons.mozilla.org/firefox/downloads/latest/i-dont-care-about-cookies/latest.xpi")
(mkExtension "keepassxc-browser@keepassxc.org" "https://addons.mozilla.org/firefox/downloads/latest/keepassxc-browser/latest.xpi")
(mkExtension "@react-devtools" "https://addons.mozilla.org/firefox/downloads/latest/react-devtools/latest.xpi")
(mkExtension "extension@redux.devtools" "https://addons.mozilla.org/firefox/downloads/latest/reduxdevtools/latest.xpi")
(mkExtension "private-relay@firefox.com" "https://addons.mozilla.org/firefox/downloads/latest/private-relay/latest.xpi")
(mkExtension "addon@darkreader.org" "file://${pkgs.callPackage ../../../patches/darkreader.nix {inherit lib stable;}}/latest.xpi")
];
example = [];
type = with lib.types; listOf anything;
description = ''
List of extensions via attrsets:
```nix
# id
# figure out the id via:
# nix run github:tupakkatapa/mozid -- 'https://addons.mozilla.org/en/firefox/addon/ublock-origin'
"uBlock0@raymondhill.net" = {
# install url
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
# method https://mozilla.github.io/policy-templates/#extensionsettings
installation_mode = "force_installed";
};
```
'';
};
configuration = lib.mkOption { configuration = lib.mkOption {
default = { default = {
EnableTrackingProtection = { EnableTrackingProtection = {