alqueva/computers/shared/fonts.nix

54 lines
1.3 KiB
Nix
Raw Normal View History

2024-10-18 00:00:48 +01:00
{
config,
pkgs,
lib,
...
}: let
cfg = config.alqueva.fonts;
inherit (lib) types mkOption;
2024-10-29 15:37:11 +00:00
mkStringsOption = default: letterform:
2024-10-18 00:00:48 +01:00
mkOption {
2024-10-29 15:37:11 +00:00
type = types.listOf types.str;
inherit default;
description = "Which ${letterform} font packages you want to use.";
2024-10-18 00:00:48 +01:00
};
in {
options.alqueva.fonts = {
2024-10-29 15:37:11 +00:00
enable = lib.mkEnableOption "" // {description = "Whether you want to use this fonts module.";};
packages = mkOption {
2024-10-18 00:00:48 +01:00
type = types.listOf types.package;
2024-10-29 15:37:11 +00:00
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";
};
2024-10-18 00:00:48 +01:00
};
};
2024-10-18 17:59:58 +01:00
config = lib.mkIf cfg.enable {
2024-10-18 00:00:48 +01:00
fonts = {
2024-10-29 15:37:11 +00:00
inherit (cfg) packages;
2024-10-18 00:00:48 +01:00
fontconfig = {
defaultFonts = {
2024-10-29 15:37:11 +00:00
inherit (cfg.names) sansSerif monospace serif emoji;
2024-10-18 00:00:48 +01:00
};
enable = true;
};
};
};
}