nixos i18n: add option to set console keymap from xkb

Close #9675. The expression was refactored heavily by vcunat.

authored by Geoffrey Reedy and committed by Vladimír Čunát 9d3da3a3 87012187

+16
+16
nixos/modules/config/i18n.nix
··· 52 52 ''; 53 53 }; 54 54 55 + consoleUseXkbConfig = mkOption { 56 + type = types.bool; 57 + default = false; 58 + description = '' 59 + If set, configure the console keymap from the xserver keyboard 60 + settings. 61 + ''; 62 + }; 63 + 55 64 consoleKeyMap = mkOption { 56 65 type = mkOptionType { 57 66 name = "string or path"; ··· 73 82 ###### implementation 74 83 75 84 config = { 85 + 86 + i18n.consoleKeyMap = with config.services.xserver; 87 + mkIf config.i18n.consoleUseXkbConfig 88 + (pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } '' 89 + '${pkgs.ckbcomp}/bin/ckbcomp' -model '${xkbModel}' -layout '${layout}' \ 90 + -option '${xkbOptions}' -variant '${xkbVariant}' > "$out" 91 + ''); 76 92 77 93 environment.systemPackages = 78 94 optional (config.i18n.supportedLocales != []) glibcLocales;