11.stylix/modules/firefox/hm.nix
bricked 079fecebad
firefox: leverage Home Manager's mkFirefoxModule pattern (#695)
Leverage Home Manager's mkFirefoxModule pattern introduced in commit
792757f643ce [1] ("firefox: support firefox derivatives").

[1]: 792757f643

Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
2024-12-25 19:24:28 +01:00

36 lines
1.2 KiB
Nix

# Consider also updating the LibreWolf module when updating this module,
# as they are very similar.
{ config, lib, ... }:
let
profileSettings = {
settings = {
"font.name.monospace.x-western" = config.stylix.fonts.monospace.name;
"font.name.sans-serif.x-western" = config.stylix.fonts.sansSerif.name;
"font.name.serif.x-western" = config.stylix.fonts.serif.name;
};
};
makeProfileSettingsPair = profileName:
lib.nameValuePair profileName profileSettings;
derivatives = [
{path = "firefox"; name = "Firefox";}
{path = "librewolf"; name = "LibreWolf";}
];
in {
options.stylix.targets = lib.listToAttrs (map (drv: lib.nameValuePair drv.path {
enable =
config.lib.stylix.mkEnableTarget drv.name true;
profileNames = lib.mkOption {
description = "The ${drv.name} profile names to apply styling on.";
type = lib.types.listOf lib.types.str;
default = [ ];
};
}) derivatives);
config = lib.mkMerge (map (drv: lib.mkIf (config.stylix.enable && config.stylix.targets.${drv.path}.enable) {
programs.${drv.path}.profiles = lib.listToAttrs
(map makeProfileSettingsPair config.stylix.targets.${drv.path}.profileNames);
}) derivatives);
}