From 7ffa701d74f047b8a1dab6d1e7c39e714c9e1013 Mon Sep 17 00:00:00 2001 From: novenary Date: Wed, 11 Jan 2023 16:16:36 +0200 Subject: [PATCH 1/2] kernel: enable Terminus 16x32 font This font was added into the kernel for high-resolution displays. It has been available since 5.0. --- pkgs/os-specific/linux/kernel/common-config.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 2fee060932ed..6a551811bbd4 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -273,6 +273,15 @@ let DRM_SIMPLEDRM = whenAtLeast "5.14" no; }; + fonts = { + FONTS = yes; + # Default fonts enabled if FONTS is not set + FONT_8x8 = yes; + FONT_8x16 = yes; + # High DPI font + FONT_TER16x32 = whenAtLeast "5.0" yes; + }; + video = { DRM_LEGACY = no; NOUVEAU_LEGACY_CTX_SUPPORT = whenAtLeast "5.2" no; From 5bb65387bf4c33753c972371cf32e625ce450c47 Mon Sep 17 00:00:00 2001 From: novenary Date: Fri, 13 Jan 2023 16:56:57 +0200 Subject: [PATCH 2/2] console: support using in-kernel fonts --- nixos/modules/config/console.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/nixos/modules/config/console.nix b/nixos/modules/config/console.nix index f5db5dc5dfc1..7c8a45bc5318 100644 --- a/nixos/modules/config/console.nix +++ b/nixos/modules/config/console.nix @@ -21,7 +21,7 @@ let # Sadly, systemd-vconsole-setup doesn't support binary keymaps. vconsoleConf = pkgs.writeText "vconsole.conf" '' KEYMAP=${cfg.keyMap} - FONT=${cfg.font} + ${optionalString (cfg.font != null) "FONT=${cfg.font}"} ''; consoleEnv = kbd: pkgs.buildEnv { @@ -45,7 +45,7 @@ in }; font = mkOption { - type = with types; either str path; + type = with types; nullOr (either str path); default = "Lat2-Terminus16"; example = "LatArCyrHeb-16"; description = mdDoc '' @@ -53,6 +53,13 @@ in whatever the {command}`setfont` program considers the default font. Can be either a font name or a path to a PSF font file. + + Use `null` to let the kernel choose a built-in font. + The default is 8x16, and, as of Linux 5.3, Terminus 32 bold for display + resolutions of 2560x1080 and higher. + These fonts cover the [IBM437][] character set. + + [IBM437]: https://en.wikipedia.org/wiki/Code_page_437 ''; }; @@ -151,7 +158,7 @@ in printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console loadkmap < ${optimizedKeymap} - ${optionalString cfg.earlySetup '' + ${optionalString (cfg.earlySetup && cfg.font != null) '' setfont -C /dev/console $extraUtils/share/consolefonts/font.psf ''} ''); @@ -168,7 +175,7 @@ in "${config.boot.initrd.systemd.package.kbd}/bin/setfont" "${config.boot.initrd.systemd.package.kbd}/bin/loadkeys" "${config.boot.initrd.systemd.package.kbd.gzip}/bin/gzip" # Fonts and keyboard layouts are compressed - ] ++ optionals (hasPrefix builtins.storeDir cfg.font) [ + ] ++ optionals (cfg.font != null && hasPrefix builtins.storeDir cfg.font) [ "${cfg.font}" ] ++ optionals (hasPrefix builtins.storeDir cfg.keyMap) [ "${cfg.keyMap}" @@ -195,7 +202,7 @@ in ]; }) - (mkIf (cfg.earlySetup && !config.boot.initrd.systemd.enable) { + (mkIf (cfg.earlySetup && cfg.font != null && !config.boot.initrd.systemd.enable) { boot.initrd.extraUtilsCommands = '' mkdir -p $out/share/consolefonts ${if substring 0 1 cfg.font == "/" then ''