From eb0b2651b87b76db4a73dfe54e07658c9b726232 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 12 Aug 2012 09:12:54 +0200 Subject: [PATCH 1/2] stage-1: Add option to load keymap during bootup. As non-QWERTY keyboards don't feel so warm and cozy if they hug QWERTY LUKS password prompts, it was on honor for me to serve King Dvorak XV to fight the glorious keyboard war against... what?! Yes, I'm awake! We're fighting with loadkeys to spit out busybox binary keymaps against loadkmap (loadkeys does have a special target -b for that). And yep, I'm somewhat abusing preLVMCommands, if someone got issues with that, feel free to introduce a new substitute in stage-i-init.sh. Sent from my iPhone --- modules/system/boot/stage-1.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/system/boot/stage-1.nix b/modules/system/boot/stage-1.nix index 01ecd839f55..b08ff733a43 100644 --- a/modules/system/boot/stage-1.nix +++ b/modules/system/boot/stage-1.nix @@ -27,6 +27,15 @@ let "; }; + boot.initrd.loadConsoleKeyMap = mkOption { + default = false; + type = with types; bool; + description = '' + Load i18n.consoleKeyMap at boot time. This is especially useful if you + bring together a non-QWERTY keyboard with a LUKS password prompt. + ''; + }; + boot.initrd.checkJournalingFS = mkOption { default = true; type = types.bool; @@ -267,6 +276,14 @@ let ''; + # the binary keymap for busybox to load at boot + busyboxKeymap = pkgs.runCommand "boottime-keymap" + { preferLocalBuild = true; } + '' + ${pkgs.kbd}/bin/loadkeys -qb "${config.i18n.consoleKeyMap}" > $out + ''; + + # The init script of boot stage 1 (loading kernel modules for # mounting the root FS). bootStage1 = pkgs.substituteAll { @@ -281,7 +298,12 @@ let inherit (config.boot) resumeDevice devSize runSize; inherit (config.boot.initrd) checkJournalingFS - preLVMCommands postDeviceCommands postMountCommands kernelModules; + postDeviceCommands postMountCommands kernelModules; + + preLVMCommands = (optionalString config.boot.initrd.loadConsoleKeyMap '' + # load boot-time keymap before any LVM/LUKS initialization + ${extraUtils}/bin/busybox loadkmap < "${busyboxKeymap}" + '') + config.boot.initrd.preLVMCommands; fsInfo = let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ]; From c9e05f1ed8130a2eda2a7838eebc792e9318cd44 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 12 Aug 2012 16:54:31 +0200 Subject: [PATCH 2/2] stage-1: Load boot-time keymap by default. This also removes the configuration option, as suggested by @edolstra. --- modules/system/boot/stage-1-init.sh | 4 ++++ modules/system/boot/stage-1.nix | 18 ++---------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/modules/system/boot/stage-1-init.sh b/modules/system/boot/stage-1-init.sh index 593b9397e66..53d528fcd56 100644 --- a/modules/system/boot/stage-1-init.sh +++ b/modules/system/boot/stage-1-init.sh @@ -147,6 +147,10 @@ modprobe scsi_wait_scan || true udevadm settle || true +# Load boot-time keymap before any LVM/LUKS initialization +@extraUtils@/bin/busybox loadkmap < "@busyboxKeymap@" + + # XXX: Use case usb->lvm will still fail, usb->luks->lvm is covered @preLVMCommands@ diff --git a/modules/system/boot/stage-1.nix b/modules/system/boot/stage-1.nix index b08ff733a43..df4e4e14035 100644 --- a/modules/system/boot/stage-1.nix +++ b/modules/system/boot/stage-1.nix @@ -27,15 +27,6 @@ let "; }; - boot.initrd.loadConsoleKeyMap = mkOption { - default = false; - type = with types; bool; - description = '' - Load i18n.consoleKeyMap at boot time. This is especially useful if you - bring together a non-QWERTY keyboard with a LUKS password prompt. - ''; - }; - boot.initrd.checkJournalingFS = mkOption { default = true; type = types.bool; @@ -293,17 +284,12 @@ let isExecutable = true; - inherit udevConf extraUtils modulesClosure; + inherit udevConf busyboxKeymap extraUtils modulesClosure; inherit (config.boot) resumeDevice devSize runSize; inherit (config.boot.initrd) checkJournalingFS - postDeviceCommands postMountCommands kernelModules; - - preLVMCommands = (optionalString config.boot.initrd.loadConsoleKeyMap '' - # load boot-time keymap before any LVM/LUKS initialization - ${extraUtils}/bin/busybox loadkmap < "${busyboxKeymap}" - '') + config.boot.initrd.preLVMCommands; + preLVMCommands postDeviceCommands postMountCommands kernelModules; fsInfo = let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ];