11.stylix/modules/zen-browser/hm.nix
Mela a378e4c090
zen-browser: support opacity (#2332)
Link: https://github.com/nix-community/stylix/pull/2332

Reviewed-by: Karun Sandhu <129101708+MrSom3body@users.noreply.github.com>
Reviewed-by: Noah Biewesch <dev@noahbiewesch.com>
Reviewed-by: 0xda157 <da157@voidq.com>
2026-06-09 08:26:12 -07:00

87 lines
2.2 KiB
Nix

{
mkTarget,
lib,
config,
options,
...
}:
mkTarget {
options = {
profileNames = lib.mkOption {
description = "The Zen Browser profile names to apply styling on.";
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "default" ];
};
enableCss = lib.mkOption {
type = lib.types.bool;
default = true;
description = "enables userChrome and userContent css styles for the browser";
};
opacityHex = lib.mkOption {
internal = true;
type = lib.types.singleLineStr;
default = "";
};
};
config = lib.optionals (options.programs ? zen-browser) [
(
{ cfg }:
{
warnings =
lib.optional (config.programs.zen-browser.enable && cfg.profileNames == [ ])
''stylix: zen-browser: `config.stylix.targets.zen-browser.profileNames` is not set. Declare profile names with 'config.stylix.targets.zen-browser.profileNames = [ "<PROFILE_NAME>" ];'.'';
}
)
(
{ opacity }:
{
stylix.targets.zen-browser.opacityHex = lib.toHexString (
builtins.ceil (opacity.applications * 255)
);
}
)
(
{ cfg, fonts }:
{
programs.zen-browser.profiles = lib.genAttrs cfg.profileNames (_: {
settings = {
"font.name.monospace.x-western" = fonts.monospace.name;
"font.name.sans-serif.x-western" = fonts.sansSerif.name;
"font.name.serif.x-western" = fonts.serif.name;
};
});
}
)
(import ../firefox/reader-mode.nix {
inherit lib;
name = "zen-browser";
})
(
{ cfg, colors }:
{
programs.zen-browser.profiles = lib.mkIf cfg.enableCss (
lib.genAttrs cfg.profileNames (_: {
settings = {
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
};
userChrome = import ./userChrome.nix {
inherit colors;
inherit (cfg) opacityHex;
};
userContent = import ./userContent.nix {
inherit colors;
inherit (cfg) opacityHex;
};
})
);
}
)
];
}