nixos i18n: add option to set console keymap from xkb

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

Changed files
+16
nixos
modules
config
+16
nixos/modules/config/i18n.nix
···
'';
};
+
consoleUseXkbConfig = mkOption {
+
type = types.bool;
+
default = false;
+
description = ''
+
If set, configure the console keymap from the xserver keyboard
+
settings.
+
'';
+
};
+
consoleKeyMap = mkOption {
type = mkOptionType {
name = "string or path";
···
###### implementation
config = {
+
+
i18n.consoleKeyMap = with config.services.xserver;
+
mkIf config.i18n.consoleUseXkbConfig
+
(pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } ''
+
'${pkgs.ckbcomp}/bin/ckbcomp' -model '${xkbModel}' -layout '${layout}' \
+
-option '${xkbOptions}' -variant '${xkbVariant}' > "$out"
+
'');
environment.systemPackages =
optional (config.i18n.supportedLocales != []) glibcLocales;