3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #23709 from lheckemann/xserver-layout-existence

xserver: check that selected layout exists
This commit is contained in:
Michael Raskin 2017-05-01 12:16:59 +02:00 committed by GitHub
commit 98a36b2847

View file

@ -258,7 +258,7 @@ in
type = types.str;
default = "us";
description = ''
Keyboard layout.
Keyboard layout, or multiple keyboard layouts separated by commas.
'';
};
@ -578,6 +578,35 @@ in
services.xserver.xkbDir = mkDefault "${pkgs.xkeyboard_config}/etc/X11/xkb";
system.extraDependencies = [
(pkgs.runCommand "xkb-layouts-exist" {
layouts=cfg.layout;
} ''
missing=()
while read -d , layout
do
[[ -f "${cfg.xkbDir}/symbols/$layout" ]] || missing+=($layout)
done <<< "$layouts,"
if [[ ''${#missing[@]} -eq 0 ]]
then
touch $out
exit 0
fi
cat >&2 <<EOF
Some of the selected keyboard layouts do not exist:
''${missing[@]}
Set services.xserver.layout to the name of an existing keyboard
layout (check ${cfg.xkbDir}/symbols for options).
EOF
exit -1
'')
];
services.xserver.config =
''
Section "ServerFlags"