Merge pull request #17082 from abbradar/fix-early-kbd

Use new early kbd-setting code in initrd and fix layouts from external packages

authored by Nikolay Amiantov and committed by GitHub 3cc54bba afcf3176

+17 -28
-4
nixos/modules/system/boot/stage-1-init.sh
··· 172 udevadm settle 173 174 175 - # Load boot-time keymap before any LVM/LUKS initialization 176 - @extraUtils@/bin/busybox loadkmap < "@busyboxKeymap@" 177 - 178 - 179 # XXX: Use case usb->lvm will still fail, usb->luks->lvm is covered 180 @preLVMCommands@ 181
··· 172 udevadm settle 173 174 175 # XXX: Use case usb->lvm will still fail, usb->luks->lvm is covered 176 @preLVMCommands@ 177
+1 -10
nixos/modules/system/boot/stage-1.nix
··· 185 }; 186 187 188 - # The binary keymap for busybox to load at boot. 189 - busyboxKeymap = pkgs.runCommand "boottime-keymap" 190 - { preferLocalBuild = true; } 191 - '' 192 - ${pkgs.kbd}/bin/loadkeys -qb "${config.i18n.consoleKeyMap}" > $out || 193 - ${pkgs.kbd}/bin/loadkeys -qbu "${config.i18n.consoleKeyMap}" > $out 194 - ''; 195 - 196 - 197 # The init script of boot stage 1 (loading kernel modules for 198 # mounting the root FS). 199 bootStage1 = pkgs.substituteAll { ··· 203 204 isExecutable = true; 205 206 - inherit udevRules extraUtils modulesClosure busyboxKeymap; 207 208 inherit (config.boot) resumeDevice devSize runSize; 209
··· 185 }; 186 187 188 # The init script of boot stage 1 (loading kernel modules for 189 # mounting the root FS). 190 bootStage1 = pkgs.substituteAll { ··· 194 195 isExecutable = true; 196 197 + inherit udevRules extraUtils modulesClosure; 198 199 inherit (config.boot) resumeDevice devSize runSize; 200
+16 -14
nixos/modules/tasks/kbd.nix
··· 14 15 optimizedKeymap = pkgs.runCommand "keymap" { 16 nativeBuildInputs = [ pkgs.kbd ]; 17 } '' 18 - cd ${kbdEnv}/share/keymaps 19 loadkeys -b ${optionalString isUnicode "-u"} "${config.i18n.consoleKeyMap}" > $out 20 ''; 21 ··· 61 default = false; 62 type = types.bool; 63 description = '' 64 - Enable setting font and keymap as early as possible (in initrd). 65 ''; 66 }; 67 ··· 83 environment.etc."vconsole.conf".source = vconsoleConf; 84 # Provide kbd with additional packages. 85 environment.etc."kbd".source = "${kbdEnv}/share"; 86 } 87 88 (mkIf (!config.boot.earlyVconsoleSetup) { ··· 111 else 112 cp -L $font $out/share/consolefonts/font.psf 113 fi 114 - ''; 115 - 116 - boot.initrd.preLVMCommands = mkBefore '' 117 - kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console 118 - printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console 119 - loadkmap < ${optimizedKeymap} 120 - 121 - setfont -C /dev/console $extraUtils/share/consolefonts/font.psf 122 - 123 - ${concatImapStringsSep "\n" (n: color: '' 124 - printf "${makeColorCS n color}" >> /dev/console 125 - '') config.i18n.consoleColors} 126 ''; 127 }) 128 ]))
··· 14 15 optimizedKeymap = pkgs.runCommand "keymap" { 16 nativeBuildInputs = [ pkgs.kbd ]; 17 + LOADKEYS_KEYMAP_PATH = "${kbdEnv}/share/keymaps/**"; 18 } '' 19 loadkeys -b ${optionalString isUnicode "-u"} "${config.i18n.consoleKeyMap}" > $out 20 ''; 21 ··· 61 default = false; 62 type = types.bool; 63 description = '' 64 + Enable setting font as early as possible (in initrd). 65 ''; 66 }; 67 ··· 83 environment.etc."vconsole.conf".source = vconsoleConf; 84 # Provide kbd with additional packages. 85 environment.etc."kbd".source = "${kbdEnv}/share"; 86 + 87 + boot.initrd.preLVMCommands = mkBefore '' 88 + kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console 89 + printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console 90 + loadkmap < ${optimizedKeymap} 91 + 92 + ${optionalString config.boot.earlyVconsoleSetup '' 93 + setfont -C /dev/console $extraUtils/share/consolefonts/font.psf 94 + ''} 95 + 96 + ${concatImapStringsSep "\n" (n: color: '' 97 + printf "${makeColorCS n color}" >> /dev/console 98 + '') config.i18n.consoleColors} 99 + ''; 100 } 101 102 (mkIf (!config.boot.earlyVconsoleSetup) { ··· 125 else 126 cp -L $font $out/share/consolefonts/font.psf 127 fi 128 ''; 129 }) 130 ]))