keyboard: make layout
and variant
optional
Also default these options to `null` for state version ≥ 19.09. Fixes #811 Suggested-by: Sean Marshallsay <srm.1708@gmail.com>
This commit is contained in:
parent
0083087e01
commit
824d31a21c
|
@ -30,6 +30,14 @@
|
||||||
Firefox package and defaults to <code>pkgs.firefox</code>.
|
Firefox package and defaults to <code>pkgs.firefox</code>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The options <option>home.keyboard.layout</option> and
|
||||||
|
<option>home.keyboard.variant</option> now default to
|
||||||
|
<literal>null</literal>, which indicates that the system value should be
|
||||||
|
used.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -55,10 +55,18 @@ let
|
||||||
keyboardSubModule = types.submodule {
|
keyboardSubModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
layout = mkOption {
|
layout = mkOption {
|
||||||
type = types.str;
|
type = with types; nullOr str;
|
||||||
default = "us";
|
default =
|
||||||
|
if versionAtLeast config.home.stateVersion "19.09"
|
||||||
|
then null
|
||||||
|
else "us";
|
||||||
|
defaultText = literalExample "null";
|
||||||
description = ''
|
description = ''
|
||||||
Keyboard layout.
|
Keyboard layout. If <literal>null</literal>, then the system
|
||||||
|
configuration will be used.
|
||||||
|
</para><para>
|
||||||
|
This defaults to <literal>null</literal> for state
|
||||||
|
version ≥ 19.09 and <literal>"us"</literal> otherwise.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,11 +89,19 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
variant = mkOption {
|
variant = mkOption {
|
||||||
type = types.str;
|
type = with types; nullOr str;
|
||||||
default = "";
|
default =
|
||||||
|
if versionAtLeast config.home.stateVersion "19.09"
|
||||||
|
then null
|
||||||
|
else "";
|
||||||
|
defaultText = literalExample "null";
|
||||||
example = "colemak";
|
example = "colemak";
|
||||||
description = ''
|
description = ''
|
||||||
X keyboard variant.
|
X keyboard variant. If <literal>null</literal>, then the
|
||||||
|
system configuration will be used.
|
||||||
|
</para><para>
|
||||||
|
This defaults to <literal>null</literal> for state
|
||||||
|
version ≥ 19.09 and <literal>""</literal> otherwise.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -104,16 +104,14 @@ in
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
ExecStart =
|
ExecStart =
|
||||||
|
with config.home.keyboard;
|
||||||
let
|
let
|
||||||
args = concatStringsSep " " (
|
args =
|
||||||
[
|
optional (layout != null) "-layout '${layout}'"
|
||||||
"-layout '${config.home.keyboard.layout}'"
|
++ optional (variant != null) "-variant '${variant}'"
|
||||||
"-variant '${config.home.keyboard.variant}'"
|
++ map (v: "-option '${v}'") options;
|
||||||
] ++
|
|
||||||
(map (v: "-option '${v}'") config.home.keyboard.options)
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
"${pkgs.xorg.setxkbmap}/bin/setxkbmap ${args}";
|
"${pkgs.xorg.setxkbmap}/bin/setxkbmap ${toString args}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
xsession-basic = ./basic.nix;
|
xsession-basic = ./basic.nix;
|
||||||
|
xsession-keyboard-without-layout = ./keyboard-without-layout.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
[Install]
|
||||||
|
WantedBy=graphical-session.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=@setxkbmap@/bin/setxkbmap -option 'ctrl:nocaps' -option 'altwin:no_win'
|
||||||
|
RemainAfterExit=true
|
||||||
|
Type=oneshot
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
After=graphical-session-pre.target
|
||||||
|
Description=Set up keyboard in X
|
||||||
|
PartOf=graphical-session.target
|
33
tests/modules/misc/xsession/keyboard-without-layout.nix
Normal file
33
tests/modules/misc/xsession/keyboard-without-layout.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
home.stateVersion = "19.09";
|
||||||
|
|
||||||
|
home.homeDirectory = "/test-home";
|
||||||
|
|
||||||
|
home.keyboard = {
|
||||||
|
options = [ "ctrl:nocaps" "altwin:no_win" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
xsession = {
|
||||||
|
enable = true;
|
||||||
|
windowManager.command = "window manager command";
|
||||||
|
importedVariables = [ "EXTRA_IMPORTED_VARIABLE" ];
|
||||||
|
initExtra = "init extra commands";
|
||||||
|
profileExtra = "profile extra commands";
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/systemd/user/setxkbmap.service
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/systemd/user/setxkbmap.service \
|
||||||
|
${pkgs.substituteAll {
|
||||||
|
src = ./keyboard-without-layout-expected.service;
|
||||||
|
inherit (pkgs.xorg) setxkbmap;
|
||||||
|
}}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue