kmscon: configure keymap from xserver xkb config

This commit is contained in:
Arthur Noel 2023-11-21 19:13:48 +00:00
parent b3f3c1b13f
commit 6447fae5d0

View File

@ -41,6 +41,12 @@ in {
}; in nullOr (nonEmptyListOf fontType);
};
useXkbConfig = mkOption {
description = "Configure keymap from xserver keyboard settings.";
type = types.bool;
default = false;
};
extraConfig = mkOption {
description = "Extra contents of the kmscon.conf file.";
type = types.lines;
@ -103,9 +109,15 @@ in {
services.kmscon.extraConfig =
let
xkb = optionals cfg.useXkbConfig
lib.mapAttrsToList (n: v: "xkb-${n}=${v}") (
lib.filterAttrs
(n: v: builtins.elem n ["layout" "model" "options" "variant"] && v != "")
config.services.xserver.xkb
);
render = optionals cfg.hwRender [ "drm" "hwaccel" ];
fonts = optional (cfg.fonts != null) "font-name=${lib.concatMapStringsSep ", " (f: f.name) cfg.fonts}";
in lib.concatStringsSep "\n" (render ++ fonts);
in lib.concatStringsSep "\n" (xkb ++ render ++ fonts);
hardware.graphics.enable = mkIf cfg.hwRender true;