Files
nix-config/modules/nixos/desktop/fonts.nix
T
Ryan Yin 46398fc688 fix(nixos): migrate kmscon to config attrset
Nixpkgs removed services.kmscon.fonts and services.kmscon.extraConfig, so the old font module failed evaluation on current nixos-unstable.

Move the selected font, font size, and hardware acceleration settings into services.kmscon.config while keeping the existing terminal type option.
2026-07-06 22:01:18 +08:00

66 lines
2.2 KiB
Nix

{ pkgs, ... }:
{
# all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts
fonts = {
# use fonts specified by user rather than default ones
enableDefaultPackages = false;
fontDir.enable = true;
# fonts are defined in /modules/base/fonts.nix, used by both NixOS & Darwin.
# packages = [ ... ];
fontconfig = {
# User defined default fonts
# https://catcat.cc/post/2021-03-07/
defaultFonts = {
serif = [
# 西文: 衬线字体(笔画末端有修饰(衬线)的字体,通常用于印刷。)
"Source Serif 4"
# 中文: 宋体(港台称明體)
"Source Han Serif SC" # 思源宋体
"Source Han Serif TC"
];
# SansSerif 也简写做 Sans, Sans 在法语中就是「without」或者「无」的意思
sansSerif = [
# 西文: 无衬线字体(指笔画末端没有修饰(衬线)的字体,通常用于屏幕显示)
"Source Sans 3"
# 中文: 黑体
"LXGW WenKai Screen" # 霞鹜文楷 屏幕阅读版
"Source Han Sans SC" # 思源黑体
"Source Han Sans TC"
];
# 等宽字体
monospace = [
# 中文
"Maple Mono NF CN" # 中英文宽度完美 2:1 的字体
"Source Han Mono SC" # 思源等宽
"Source Han Mono TC"
# 西文
"JetBrainsMono Nerd Font"
];
emoji = [ "Noto Color Emoji" ];
};
antialias = true; # 抗锯齿
hinting.enable = false; # 禁止字体微调 - 高分辨率下没这必要
subpixel = {
rgba = "rgb"; # IPS 屏幕使用 rgb 排列
};
};
};
# https://wiki.archlinux.org/title/KMSCON
services.kmscon = {
# Use kmscon as the virtual console instead of gettys.
# kmscon is a kms/dri-based userspace virtual terminal implementation.
# It supports a richer feature set than the standard linux console VT,
# including full unicode support, and when the video card supports drm should be much faster.
enable = true;
extraOptions = "--term xterm-256color";
config = {
font-name = "Maple Mono NF CN";
font-size = 14;
hwaccel = true;
};
};
}