git.iko.soy/typeable/nixpkgs
on master help sign in
xserver: check that selected layout exists

Fixes #5638

commitc5c0459a60c1e64afc66c3b76434b88961d67abb authorLinus Heckemann <git@sphalerite.org> dateThu 23 Mar 2017, 20:06 (10 years ago) parentc2b9b80
1 file changed+29
nixos/modules/services/x11/xserver.nix+29
nixos/modules/services/x11/xserver.nix+29
@@ -578,6 +578,35 @@ in
578578
579579 services.xserver.xkbDir = mkDefault "${pkgs.xkeyboard_config}/etc/X11/xkb";
580580
581+ system.extraDependencies = [
582+ (pkgs.runCommand "xkb-layouts-exist" {
583+ layouts=cfg.layout;
584+ } ''
585+ missing=()
586+ while read -d , layout
587+ do
588+ [[ -f "${cfg.xkbDir}/symbols/$layout" ]] || missing+=($layout)
589+ done <<< "$layouts,"
590+ if [[ ''${#missing[@]} -eq 0 ]]
591+ then
592+ touch $out
593+ exit 0
594+ fi
595+
596+ cat >&2 <<EOF
597+
598+ Some of the selected keyboard layouts do not exist:
599+
600+ ''${missing[@]}
601+
602+ Set services.xserver.layout to the name of an existing keyboard
603+ layout (check ${cfg.xkbDir}/symbols for options).
604+
605+ EOF
606+ exit -1
607+ '')
608+ ];
609+
581610 services.xserver.config =
582611 ''
583612 Section "ServerFlags"