Merge pull request #210205 from 9ary/kernel-fonts

Build the large Terminus font into the kernel

authored by

Ryan Lahfa and committed by
GitHub
618ba949 704fe52e

+21 -5
+12 -5
nixos/modules/config/console.nix
··· 21 21 # Sadly, systemd-vconsole-setup doesn't support binary keymaps. 22 22 vconsoleConf = pkgs.writeText "vconsole.conf" '' 23 23 KEYMAP=${cfg.keyMap} 24 - FONT=${cfg.font} 24 + ${optionalString (cfg.font != null) "FONT=${cfg.font}"} 25 25 ''; 26 26 27 27 consoleEnv = kbd: pkgs.buildEnv { ··· 45 45 }; 46 46 47 47 font = mkOption { 48 - type = with types; either str path; 48 + type = with types; nullOr (either str path); 49 49 default = "Lat2-Terminus16"; 50 50 example = "LatArCyrHeb-16"; 51 51 description = mdDoc '' ··· 53 53 whatever the {command}`setfont` program considers the 54 54 default font. 55 55 Can be either a font name or a path to a PSF font file. 56 + 57 + Use `null` to let the kernel choose a built-in font. 58 + The default is 8x16, and, as of Linux 5.3, Terminus 32 bold for display 59 + resolutions of 2560x1080 and higher. 60 + These fonts cover the [IBM437][] character set. 61 + 62 + [IBM437]: https://en.wikipedia.org/wiki/Code_page_437 56 63 ''; 57 64 }; 58 65 ··· 151 158 printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console 152 159 loadkmap < ${optimizedKeymap} 153 160 154 - ${optionalString cfg.earlySetup '' 161 + ${optionalString (cfg.earlySetup && cfg.font != null) '' 155 162 setfont -C /dev/console $extraUtils/share/consolefonts/font.psf 156 163 ''} 157 164 ''); ··· 168 175 "${config.boot.initrd.systemd.package.kbd}/bin/setfont" 169 176 "${config.boot.initrd.systemd.package.kbd}/bin/loadkeys" 170 177 "${config.boot.initrd.systemd.package.kbd.gzip}/bin/gzip" # Fonts and keyboard layouts are compressed 171 - ] ++ optionals (hasPrefix builtins.storeDir cfg.font) [ 178 + ] ++ optionals (cfg.font != null && hasPrefix builtins.storeDir cfg.font) [ 172 179 "${cfg.font}" 173 180 ] ++ optionals (hasPrefix builtins.storeDir cfg.keyMap) [ 174 181 "${cfg.keyMap}" ··· 195 202 ]; 196 203 }) 197 204 198 - (mkIf (cfg.earlySetup && !config.boot.initrd.systemd.enable) { 205 + (mkIf (cfg.earlySetup && cfg.font != null && !config.boot.initrd.systemd.enable) { 199 206 boot.initrd.extraUtilsCommands = '' 200 207 mkdir -p $out/share/consolefonts 201 208 ${if substring 0 1 cfg.font == "/" then ''
+9
pkgs/os-specific/linux/kernel/common-config.nix
··· 283 283 DRM_SIMPLEDRM = whenAtLeast "5.14" no; 284 284 }; 285 285 286 + fonts = { 287 + FONTS = yes; 288 + # Default fonts enabled if FONTS is not set 289 + FONT_8x8 = yes; 290 + FONT_8x16 = yes; 291 + # High DPI font 292 + FONT_TER16x32 = whenAtLeast "5.0" yes; 293 + }; 294 + 286 295 video = { 287 296 DRM_LEGACY = no; 288 297 NOUVEAU_LEGACY_CTX_SUPPORT = whenBetween "5.2" "6.3" no;