alqueva/computers/shared/fonts.nix
2024-10-29 15:37:11 +00:00

53 lines
1.3 KiB
Nix

{
config,
pkgs,
lib,
...
}: let
cfg = config.alqueva.fonts;
inherit (lib) types mkOption;
mkStringsOption = default: letterform:
mkOption {
type = types.listOf types.str;
inherit default;
description = "Which ${letterform} font packages you want to use.";
};
in {
options.alqueva.fonts = {
enable = lib.mkEnableOption "" // {description = "Whether you want to use this fonts module.";};
packages = mkOption {
type = types.listOf types.package;
default = [pkgs.roboto pkgs.roboto-serif pkgs.roboto-mono pkgs.noto-fonts-color-emoji];
description = "Packages related to fonts to be installed.";
};
names = builtins.mapAttrs (_n: v: mkStringsOption v.default v.letterform) {
sansSerif = {
default = ["Roboto"];
letterform = "sans-serif";
};
monospace = {
default = ["Roboto Mono"];
letterform = "monospace";
};
serif = {
default = ["Roboto Serif"];
letterform = "serif";
};
emoji = {
default = ["Noto Color Emoji"];
letterform = "emoji";
};
};
};
config = lib.mkIf cfg.enable {
fonts = {
inherit (cfg) packages;
fontconfig = {
defaultFonts = {
inherit (cfg.names) sansSerif monospace serif emoji;
};
enable = true;
};
};
};
}