{
  config,
  pkgs,
  lib,
  ...
}: let
  cfg = config.alqueva.system.fonts;
  inherit (lib) types mkOption;
  mkStringsOption = default: letterform:
    mkOption {
      type = types.listOf types.str;
      inherit default;
      description = "The default fonts for ${letterform}.";
    };
  mkPackagesOption = default: letterform:
    mkOption {
      type = types.listOf types.package;
      inherit default;
      description = "The packages you want to use for your ${letterform} fonts.";
    };
in {
  options.alqueva.system.fonts = {
    enable = lib.mkEnableOption "" // {description = "Whether you want to use this fonts module.";};
    packages =
      {
        extra = mkOption {
          type = types.listOf types.package;
          default = [];
          description = "Extra font packages you want installed.";
        };
      }
      // builtins.mapAttrs (_n: v: mkPackagesOption v.default v.letterform) {
        sansSerif = {
          default = [pkgs.roboto];
          letterform = "sans-serif";
        };
        monospace = {
          default = [pkgs.roboto-mono];
          letterform = "monospace";
        };
        serif = {
          default = [pkgs.roboto-serif];
          letterform = "serif";
        };
        emoji = {
          default = [pkgs.noto-fonts-color-emoji];
          letterform = "emoji";
        };
      };
    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 = {
      packages = builtins.concatLists (builtins.attrValues cfg.packages);
      fontconfig = {
        defaultFonts = {
          inherit (cfg.names) sansSerif monospace serif emoji;
        };
        enable = true;
      };
    };
  };
}
