···204 XKB
205 </link>
206 keyboard layouts using the option
207- <option>
208- <link linkend="opt-services.xserver.extraLayouts">
209- services.xserver.extraLayouts
210- </link>
211- </option>.
212 As a first example, we are going to create a layout based on the basic US
213 layout, with an additional layer to type some greek symbols by pressing the
214 right-alt key.
215 </para>
216 <para>
217- To do this we are going to create a <literal>us-greek</literal> file
218- with a <literal>xkb_symbols</literal> section.
0219 </para>
220<programlisting>
221xkb_symbols "us-greek"
···231};
232</programlisting>
233 <para>
234- To install the layout, the filepath, a description and the list of
235- languages must be given:
236 </para>
237<programlisting>
238<xref linkend="opt-services.xserver.extraLayouts"/>.us-greek = {
239 description = "US layout with alt-gr greek";
240 languages = [ "eng" ];
241- symbolsFile = /path/to/us-greek;
242}
243</programlisting>
244 <note>
···248 </para>
249 </note>
250 <para>
251- The layout should now be installed and ready to use: try it by
252- running <literal>setxkbmap us-greek</literal> and type
253- <literal><alt>+a</literal>. To change the default the usual
000000000000000000254 <option>
255 <link linkend="opt-services.xserver.layout">
256 services.xserver.layout
···204 XKB
205 </link>
206 keyboard layouts using the option
207+ <option><link linkend="opt-services.xserver.extraLayouts">
208+ services.xserver.extraLayouts</link></option>.
209+ </para>
210+ <para>
0211 As a first example, we are going to create a layout based on the basic US
212 layout, with an additional layer to type some greek symbols by pressing the
213 right-alt key.
214 </para>
215 <para>
216+ Create a file called <literal>us-greek</literal> with the following
217+ content (under a directory called <literal>symbols</literal>; it's
218+ an XKB peculiarity that will help with testing):
219 </para>
220<programlisting>
221xkb_symbols "us-greek"
···231};
232</programlisting>
233 <para>
234+ A minimal layout specification must include the following:
0235 </para>
236<programlisting>
237<xref linkend="opt-services.xserver.extraLayouts"/>.us-greek = {
238 description = "US layout with alt-gr greek";
239 languages = [ "eng" ];
240+ symbolsFile = /yourpath/symbols/us-greek;
241}
242</programlisting>
243 <note>
···247 </para>
248 </note>
249 <para>
250+ Applying this customization requires rebuilding several packages,
251+ and a broken XKB file can lead to the X session crashing at login.
252+ Therefore, you're strongly advised to <emphasis role="strong">test
253+ your layout before applying it</emphasis>:
254+<screen>
255+<prompt>$ </prompt>nix-shell -p xorg.xkbcomp
256+<prompt>$ </prompt>setxkbmap -I/yourpath us-greek -print | xkbcomp -I/yourpath - $DISPLAY
257+</screen>
258+ </para>
259+ <para>
260+ You can inspect the predefined XKB files for examples:
261+<screen>
262+<prompt>$ </prompt>echo "$(nix-build --no-out-link '<nixpkgs>' -A xorg.xkeyboardconfig)/etc/X11/xkb/"
263+</screen>
264+ </para>
265+ <para>
266+ Once the configuration is applied, and you did a logout/login
267+ cycle, the layout should be ready to use. You can try it by e.g.
268+ running <literal>setxkbmap us-greek</literal> and then type
269+ <literal><alt>+a</literal> (it may not get applied in your
270+ terminal straight away). To change the default, the usual
271 <option>
272 <link linkend="opt-services.xserver.layout">
273 services.xserver.layout