firefox: add colorTheme.enable option (#881)

Add the colorTheme.enable option to the Firefox derivatives by
installing the the Firefox Color extension.

This is not enabled by default because writing extension settings
requires manually setting 'extensions.force = true'. [1]

[1]: https://github.com/nix-community/home-manager/pull/6490

Link: https://github.com/danth/stylix/pull/881

Reviewed-by: Daniel Thwaites <danth@danth.me>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
bricked 2025-02-22 16:27:39 +00:00 committed by GitHub
parent 917e07af14
commit 3a686a20b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 142 additions and 2 deletions

View file

@ -1,4 +1,9 @@
{ config, lib, ... }:
{
config,
lib,
pkgs,
...
}:
let
targets = [
@ -30,6 +35,17 @@ let
})
) targets
);
mkColor =
color:
let
inherit (config.lib.stylix) colors;
in
{
r = colors."${color}-rgb-r";
g = colors."${color}-rgb-g";
b = colors."${color}-rgb-b";
};
nur = config.lib.stylix.templates.nur.legacyPackages.${pkgs.system};
in
{
options.stylix.targets = lib.listToAttrs (
@ -44,6 +60,10 @@ in
default = [ ];
};
colorTheme.enable = config.lib.stylix.mkEnableTarget ''
[Firefox Color](https://color.firefox.com/) theme
'' false;
firefoxGnomeTheme.enable = config.lib.stylix.mkEnableTarget ''
[Firefox GNOME
theme](https://github.com/rafaelmardojai/firefox-gnome-theme)
@ -79,9 +99,58 @@ in
);
userContent = ''
@import "firefox-gnome-theme/userContent.css";
import "firefox-gnome-theme/userContent.css";
'';
})
(lib.mkIf cfg.colorTheme.enable {
extensions = {
packages = [ nur.repos.rycee.firefox-addons.firefox-color ];
settings."FirefoxColor@mozilla.com".settings = {
firstRunDone = true;
theme = {
title = "Stylix ${config.lib.stylix.colors.description}";
images.additional_backgrounds = [ "./bg-000.svg" ];
colors = {
toolbar = mkColor "base00";
toolbar_text = mkColor "base05";
frame = mkColor "base01";
tab_background_text = mkColor "base05";
toolbar_field = mkColor "base02";
toolbar_field_text = mkColor "base05";
tab_line = mkColor "base0D";
popup = mkColor "base00";
popup_text = mkColor "base05";
button_background_active = mkColor "base04";
frame_inactive = mkColor "base00";
icons_attention = mkColor "base0D";
icons = mkColor "base05";
ntp_background = mkColor "base00";
ntp_text = mkColor "base05";
popup_border = mkColor "base0D";
popup_highlight_text = mkColor "base05";
popup_highlight = mkColor "base04";
sidebar_border = mkColor "base0D";
sidebar_highlight_text = mkColor "base05";
sidebar_highlight = mkColor "base0D";
sidebar_text = mkColor "base05";
sidebar = mkColor "base00";
tab_background_separator = mkColor "base0D";
tab_loading = mkColor "base05";
tab_selected = mkColor "base00";
tab_text = mkColor "base05";
toolbar_bottom_separator = mkColor "base00";
toolbar_field_border_focus = mkColor "base0D";
toolbar_field_border = mkColor "base00";
toolbar_field_focus = mkColor "base00";
toolbar_field_highlight_text = mkColor "base00";
toolbar_field_highlight = mkColor "base0D";
toolbar_field_separator = mkColor "base0D";
toolbar_vertical_separator = mkColor "base0D";
};
};
};
};
})
];
}) cfg.profileNames
);