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

@ -1,172 +1,140 @@
# credits to Voronind for darkreader config https://github.com/voronind-com/nix/blob/main/home/program/firefox/default.nix # credits to Voronind for darkreader config https://github.com/voronind-com/nix/blob/main/home/program/firefox/default.nix
{ {
lib, lib,
config, config,
options, options,
inputs, inputs,
stable, stable,
system, system,
pkgs, pkgs,
... ...
}: let }: let
# at time of using this here, stylix might not be evaluated yet # at time of using this here, stylix might not be evaluated yet
# 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} = { in {
inherit install_url; imports = [
installation_mode = "normal_installed"; (import ./ffextensions.nix
}; {inherit lib stable pkgs name;})
}; ];
in { options.mods.browser.${name} = {
options.mods.browser.zen = { 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"; };
}; configuration = lib.mkOption {
extensions = lib.mkOption { default = {
default = [ EnableTrackingProtection = {
(mkExtension "uBlock0@raymondhill.net" "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi") Value = true;
(mkExtension "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" "https://addons.mozilla.org/firefox/downloads/latest/user-agent-string-switcher/latest.xpi") Locked = true;
(mkExtension "{d7742d87-e61d-4b78-b8a1-b469842139fa}" "https://addons.mozilla.org/firefox/downloads/latest/vimium-ff/latest.xpi") Cryptomining = true;
(mkExtension "firefox@ghostery.com" "https://addons.mozilla.org/firefox/downloads/latest/ghostery/latest.xpi") Fingerprinting = true;
(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") DisablePocket = true;
(mkExtension "keepassxc-browser@keepassxc.org" "https://addons.mozilla.org/firefox/downloads/latest/keepassxc-browser/latest.xpi") CaptivePortal = false;
(mkExtension "@react-devtools" "https://addons.mozilla.org/firefox/downloads/latest/react-devtools/latest.xpi") DisableFirefoxStudies = true;
(mkExtension "extension@redux.devtools" "https://addons.mozilla.org/firefox/downloads/latest/reduxdevtools/latest.xpi") DisableTelemetry = true;
(mkExtension "private-relay@firefox.com" "https://addons.mozilla.org/firefox/downloads/latest/private-relay/latest.xpi") NoDefaultBookmarks = true;
(mkExtension "addon@darkreader.org" "file://${pkgs.callPackage ../../../patches/darkreader.nix {inherit lib stable;}}/latest.xpi") PasswordManagerEnabled = false;
]; FirefoxHome = {
example = []; Search = true;
type = with lib.types; listOf anything; Pocket = false;
description = '' Snippets = false;
List of extensions via attrsets: TopSites = true;
```nix Highlights = false;
# id };
# figure out the id via: UserMessaging = {
# nix run github:tupakkatapa/mozid -- 'https://addons.mozilla.org/en/firefox/addon/ublock-origin' ExtensionRecommendations = false;
"uBlock0@raymondhill.net" = { SkipOnboarding = true;
# install url };
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"; "3rdparty".Extensions = {
# method https://mozilla.github.io/policy-templates/#extensionsettings "addon@darkreader.org" = {
installation_mode = "force_installed"; theme = {
}; darkSchemeBackgroundColor = "#${scheme.base00}";
``` darkSchemeTextColor = "#${scheme.base05}";
''; };
}; previewNewDesign = true;
configuration = lib.mkOption { };
default = { };
EnableTrackingProtection = { };
Value = true; example = {};
Locked = true; type = with lib.types; attrsOf anything;
Cryptomining = true; description = "Zen policy configuration. See https://mozilla.github.io/policy-templates for more information.";
Fingerprinting = true; };
}; profiles = lib.mkOption {
DisablePocket = true; default = [
CaptivePortal = false; {
DisableFirefoxStudies = true; name = "${config.conf.username}";
DisableTelemetry = true; value = {
NoDefaultBookmarks = true; settings = {
PasswordManagerEnabled = false; "zen.view.compact.hide-tabbar" = false;
FirefoxHome = { "zen.view.compact.hide-toolbar" = true;
Search = true; "zen.view.sidebar-expanded" = false;
Pocket = false; "zen.view.use-single-toolbar" = false;
Snippets = false; "zen.view.welcome-screen.seen" = true;
TopSites = true; "zen.theme.accent-color" = "#b4bbff";
Highlights = false; "extensions.autoDisableScopes" = 0;
}; "cookiebanners.service.mode" = 2;
UserMessaging = { };
ExtensionRecommendations = false; isDefault = true;
SkipOnboarding = true; id = 0;
}; };
"3rdparty".Extensions = { }
"addon@darkreader.org" = { {
theme = { name = "special";
darkSchemeBackgroundColor = "#${scheme.base00}"; value = {
darkSchemeTextColor = "#${scheme.base05}"; settings = {
}; "zen.view.compact.hide-tabbar" = false;
previewNewDesign = true; "zen.view.compact.hide-toolbar" = true;
}; "zen.view.sidebar-expanded" = false;
}; "zen.view.use-single-toolbar" = false;
}; "zen.view.welcome-screen.seen" = true;
example = {}; "zen.theme.accent-color" = "#b4bbff";
type = with lib.types; attrsOf anything; "extensions.autoDisableScopes" = 0;
description = "Zen policy configuration. See https://mozilla.github.io/policy-templates for more information."; };
}; isDefault = false;
profiles = lib.mkOption { id = 1;
default = [ };
{ }
name = "${config.conf.username}"; ];
value = { example = [
settings = { {
"zen.view.compact.hide-tabbar" = false; name = "custom";
"zen.view.compact.hide-toolbar" = true; value = {
"zen.view.sidebar-expanded" = false; settings = {
"zen.view.use-single-toolbar" = false; extensions.autoDisableScopes = 0;
"zen.view.welcome-screen.seen" = true; };
"zen.theme.accent-color" = "#b4bbff"; extensions.packages = [pkgs.nur.repos.rycee.firefox-addons.darkreader];
"extensions.autoDisableScopes" = 0; isDefault = true;
"cookiebanners.service.mode" = 2; id = 0;
}; };
isDefault = true; }
id = 0; ];
}; type = with lib.types; listOf (attrsOf anything);
} description = "Zen profiles";
{ };
name = "special"; };
value = { config = lib.mkIf (config.mods.browser.zen.enable || config.mods.homePackages.browser == "zen") (
settings = { lib.optionalAttrs (options ? home.packages) {
"zen.view.compact.hide-tabbar" = false; programs.zen-browser = {
"zen.view.compact.hide-toolbar" = true; enable = true;
"zen.view.sidebar-expanded" = false; package =
"zen.view.use-single-toolbar" = false; pkgs.wrapFirefox
"zen.view.welcome-screen.seen" = true; inputs.zen-browser.packages.${system}.zen-browser-unwrapped
"zen.theme.accent-color" = "#b4bbff"; {
"extensions.autoDisableScopes" = 0; pname = "zen-browser";
}; extraPolicies =
isDefault = false; config.mods.browser.zen.configuration
id = 1; // {
}; ExtensionSettings = builtins.foldl' (acc: ext: acc // ext) {} config.mods.browser.zen.extensions;
} };
]; };
example = [ profiles = builtins.listToAttrs config.mods.browser.zen.profiles;
{ };
name = "custom"; }
value = { );
settings = { }
extensions.autoDisableScopes = 0;
};
extensions.packages = [pkgs.nur.repos.rycee.firefox-addons.darkreader];
isDefault = true;
id = 0;
};
}
];
type = with lib.types; listOf (attrsOf anything);
description = "Zen profiles";
};
};
config = lib.mkIf (config.mods.browser.zen.enable || config.mods.homePackages.browser == "zen") (
lib.optionalAttrs (options ? home.packages) {
programs.zen-browser = {
enable = true;
package =
pkgs.wrapFirefox
inputs.zen-browser.packages.${system}.zen-browser-unwrapped
{
pname = "zen-browser";
extraPolicies =
config.mods.browser.zen.configuration
// {
ExtensionSettings = builtins.foldl' (acc: ext: acc // ext) {} config.mods.browser.zen.extensions;
};
};
profiles = builtins.listToAttrs config.mods.browser.zen.profiles;
};
}
);
}