2014-08-24 18:18:18 +01:00
|
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-x11">
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<title>X Window System</title>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
The X Window System (X11) provides the basis of NixOS’ graphical user
|
|
|
|
|
interface. It can be enabled as follows:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.enable"/> = true;
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
The X server will automatically detect and use the appropriate video driver
|
|
|
|
|
from a set of X.org drivers (such as <literal>vesa</literal> and
|
|
|
|
|
<literal>intel</literal>). You can also specify a driver manually, e.g.
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "r128" ];
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
to enable X.org’s <literal>xf86-video-r128</literal> driver.
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
You also need to enable at least one desktop or window manager. Otherwise,
|
|
|
|
|
you can only log into a plain undecorated <command>xterm</command> window.
|
|
|
|
|
Thus you should pick one or more of the following lines:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.desktopManager.plasma5.enable"/> = true;
|
|
|
|
|
<xref linkend="opt-services.xserver.desktopManager.xfce.enable"/> = true;
|
|
|
|
|
<xref linkend="opt-services.xserver.desktopManager.gnome3.enable"/> = true;
|
2018-08-04 07:23:54 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.desktopManager.mate.enable"/> = true;
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.windowManager.xmonad.enable"/> = true;
|
|
|
|
|
<xref linkend="opt-services.xserver.windowManager.twm.enable"/> = true;
|
|
|
|
|
<xref linkend="opt-services.xserver.windowManager.icewm.enable"/> = true;
|
|
|
|
|
<xref linkend="opt-services.xserver.windowManager.i3.enable"/> = true;
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
NixOS’s default <emphasis>display manager</emphasis> (the program that
|
|
|
|
|
provides a graphical login prompt and manages the X server) is LightDM. You
|
|
|
|
|
can select an alternative one by picking one of the following lines:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.displayManager.sddm.enable"/> = true;
|
2019-01-18 17:11:00 +00:00
|
|
|
|
<xref linkend="opt-services.xserver.displayManager.slim.enable"/> = true;
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
|
|
|
|
You can set the keyboard layout (and optionally the layout variant):
|
2017-06-17 20:37:25 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.layout"/> = "de";
|
|
|
|
|
<xref linkend="opt-services.xserver.xkbVariant"/> = "neo";
|
2017-06-17 20:37:25 +01:00
|
|
|
|
</programlisting>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
The X server is started automatically at boot time. If you don’t want this
|
|
|
|
|
to happen, you can set:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.autorun"/> = false;
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
The X server can then be started manually:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<screen>
|
2016-06-01 15:23:32 +01:00
|
|
|
|
# systemctl start display-manager.service
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</screen>
|
2019-04-27 11:33:27 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
On 64-bit systems, if you want OpenGL for 32-bit programs such as in Wine,
|
|
|
|
|
you should also set the following:
|
2019-04-27 11:33:27 +01:00
|
|
|
|
<programlisting>
|
|
|
|
|
<xref linkend="opt-hardware.opengl.driSupport32Bit"/> = true;
|
|
|
|
|
</programlisting>
|
|
|
|
|
</para>
|
|
|
|
|
<simplesect xml:id="sec-x11-auto-login">
|
2019-03-13 05:23:05 +00:00
|
|
|
|
<title>Auto-login</title>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
The x11 login screen can be skipped entirely, automatically logging you into
|
|
|
|
|
your window manager and desktop environment when you boot your computer.
|
2019-03-13 05:23:05 +00:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
This is especially helpful if you have disk encryption enabled. Since you
|
|
|
|
|
already have to provide a password to decrypt your disk, entering a second
|
|
|
|
|
password to login can be redundant.
|
2019-03-13 05:23:05 +00:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
To enable auto-login, you need to define your default window manager and
|
|
|
|
|
desktop environment. If you wanted no desktop environment and i3 as your your
|
|
|
|
|
window manager, you'd define:
|
2019-03-13 05:23:05 +00:00
|
|
|
|
<programlisting>
|
|
|
|
|
<xref linkend="opt-services.xserver.desktopManager.default"/> = "none";
|
|
|
|
|
<xref linkend="opt-services.xserver.windowManager.default"/> = "i3";
|
|
|
|
|
</programlisting>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
And, finally, to enable auto-login for a user <literal>johndoe</literal>:
|
2019-03-13 05:23:05 +00:00
|
|
|
|
<programlisting>
|
|
|
|
|
<xref linkend="opt-services.xserver.displayManager.auto.enable"/> = true;
|
|
|
|
|
<xref linkend="opt-services.xserver.displayManager.auto.user"/> = "johndoe";
|
|
|
|
|
</programlisting>
|
|
|
|
|
</para>
|
|
|
|
|
</simplesect>
|
2018-09-02 20:45:04 +01:00
|
|
|
|
<simplesect xml:id="sec-x11-graphics-cards-nvidia">
|
2019-03-22 12:59:48 +00:00
|
|
|
|
<title>Proprietary NVIDIA drivers</title>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
NVIDIA provides a proprietary driver for its graphics cards that has better
|
|
|
|
|
3D performance than the X.org drivers. It is not enabled by default because
|
|
|
|
|
it’s not free software. You can enable it as follows:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidia" ];
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
Or if you have an older card, you may have to use one of the legacy drivers:
|
2015-09-02 12:18:09 +01:00
|
|
|
|
<programlisting>
|
2019-03-22 12:59:48 +00:00
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy390" ];
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy340" ];
|
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy304" ];
|
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "nvidiaLegacy173" ];
|
2015-09-02 12:18:09 +01:00
|
|
|
|
</programlisting>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
You may need to reboot after enabling this driver to prevent a clash with
|
|
|
|
|
other kernel modules.
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
</simplesect>
|
2018-09-02 20:45:04 +01:00
|
|
|
|
<simplesect xml:id="sec-x11--graphics-cards-amd">
|
2019-03-22 12:59:48 +00:00
|
|
|
|
<title>Proprietary AMD drivers</title>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
AMD provides a proprietary driver for its graphics cards that has better 3D
|
|
|
|
|
performance than the X.org drivers. It is not enabled by default because
|
|
|
|
|
it’s not free software. You can enable it as follows:
|
2014-09-07 03:42:32 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.videoDrivers"/> = [ "ati_unfree" ];
|
2014-09-07 03:42:32 +01:00
|
|
|
|
</programlisting>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
You will need to reboot after enabling this driver to prevent a clash with
|
|
|
|
|
other kernel modules.
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
2019-07-22 09:05:56 +01:00
|
|
|
|
<note>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
<para>
|
|
|
|
|
For recent AMD GPUs you most likely want to keep either the defaults
|
|
|
|
|
or <literal>"amdgpu"</literal> (both free).
|
|
|
|
|
</para>
|
2019-07-22 09:05:56 +01:00
|
|
|
|
</note>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</simplesect>
|
2018-09-02 20:45:04 +01:00
|
|
|
|
<simplesect xml:id="sec-x11-touchpads">
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<title>Touchpads</title>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
Support for Synaptics touchpads (found in many laptops such as the Dell
|
|
|
|
|
Latitude series) can be enabled as follows:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.libinput.enable"/> = true;
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
The driver has many options (see <xref linkend="ch-options"/>). For
|
|
|
|
|
instance, the following disables tap-to-click behavior:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<programlisting>
|
2018-04-05 09:43:56 +01:00
|
|
|
|
<xref linkend="opt-services.xserver.libinput.tapping"/> = false;
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</programlisting>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
Note: the use of <literal>services.xserver.synaptics</literal> is deprecated
|
|
|
|
|
since NixOS 17.09.
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
</simplesect>
|
2018-09-02 20:45:04 +01:00
|
|
|
|
<simplesect xml:id="sec-x11-gtk-and-qt-themes">
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<title>GTK/Qt themes</title>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
GTK themes can be installed either to user profile or system-wide (via
|
|
|
|
|
<literal>environment.systemPackages</literal>). To make Qt 5 applications
|
|
|
|
|
look similar to GTK2 ones, you can install <literal>qt5.qtbase.gtk</literal>
|
|
|
|
|
package into your system environment. It should work for all Qt 5 library
|
|
|
|
|
versions.
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
|
|
|
|
</simplesect>
|
2019-07-22 09:06:20 +01:00
|
|
|
|
<simplesect xml:id="custom-xkb-layouts">
|
|
|
|
|
<title>Custom XKB layouts</title>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
It is possible to install custom
|
|
|
|
|
<link xlink:href="https://en.wikipedia.org/wiki/X_keyboard_extension">
|
|
|
|
|
XKB
|
|
|
|
|
</link>
|
|
|
|
|
keyboard layouts using the option
|
|
|
|
|
<option>
|
|
|
|
|
<link linkend="opt-services.xserver.extraLayouts">
|
|
|
|
|
services.xserver.extraLayouts
|
|
|
|
|
</link>
|
|
|
|
|
</option>.
|
|
|
|
|
As a first example, we are going to create a layout based on the basic US
|
|
|
|
|
layout, with an additional layer to type some greek symbols by pressing the
|
|
|
|
|
right-alt key.
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
To do this we are going to create a <literal>us-greek</literal> file
|
|
|
|
|
with a <literal>xkb_symbols</literal> section.
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
xkb_symbols "us-greek"
|
|
|
|
|
{
|
|
|
|
|
include "us(basic)" // includes the base US keys
|
|
|
|
|
include "level3(ralt_switch)" // configures right alt as a third level switch
|
|
|
|
|
|
|
|
|
|
key <LatA> { [ a, A, Greek_alpha ] };
|
|
|
|
|
key <LatB> { [ b, B, Greek_beta ] };
|
|
|
|
|
key <LatG> { [ g, G, Greek_gamma ] };
|
|
|
|
|
key <LatD> { [ d, D, Greek_delta ] };
|
|
|
|
|
key <LatZ> { [ z, Z, Greek_zeta ] };
|
|
|
|
|
};
|
|
|
|
|
</programlisting>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
To install the layout, the filepath, a description and the list of
|
|
|
|
|
languages must be given:
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
<xref linkend="opt-services.xserver.extraLayouts"/>.us-greek = {
|
|
|
|
|
description = "US layout with alt-gr greek";
|
|
|
|
|
languages = [ "eng" ];
|
|
|
|
|
symbolsFile = /path/to/us-greek;
|
|
|
|
|
}
|
|
|
|
|
</programlisting>
|
|
|
|
|
<note>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
<para>
|
|
|
|
|
The name should match the one given to the
|
|
|
|
|
<literal>xkb_symbols</literal> block.
|
|
|
|
|
</para>
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</note>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
The layout should now be installed and ready to use: try it by
|
|
|
|
|
running <literal>setxkbmap us-greek</literal> and type
|
|
|
|
|
<literal><alt>+a</literal>. To change the default the usual
|
|
|
|
|
<option>
|
|
|
|
|
<link linkend="opt-services.xserver.layout">
|
|
|
|
|
services.xserver.layout
|
|
|
|
|
</link>
|
|
|
|
|
</option>
|
|
|
|
|
option can still be used.
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
A layout can have several other components besides
|
|
|
|
|
<literal>xkb_symbols</literal>, for example we will define new
|
|
|
|
|
keycodes for some multimedia key and bind these to some symbol.
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
Use the <emphasis>xev</emphasis> utility from
|
|
|
|
|
<literal>pkgs.xorg.xev</literal> to find the codes of the keys of
|
|
|
|
|
interest, then create a <literal>media-key</literal> file to hold
|
|
|
|
|
the keycodes definitions
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
xkb_keycodes "media"
|
|
|
|
|
{
|
|
|
|
|
<volUp> = 123;
|
|
|
|
|
<volDown> = 456;
|
|
|
|
|
}
|
|
|
|
|
</programlisting>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
Now use the newly define keycodes in <literal>media-sym</literal>:
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
xkb_symbols "media"
|
|
|
|
|
{
|
|
|
|
|
key.type = "ONE_LEVEL";
|
|
|
|
|
key <volUp> { [ XF86AudioLowerVolume ] };
|
|
|
|
|
key <volDown> { [ XF86AudioRaiseVolume ] };
|
|
|
|
|
}
|
|
|
|
|
</programlisting>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
As before, to install the layout do
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
<xref linkend="opt-services.xserver.extraLayouts"/>.media = {
|
|
|
|
|
description = "Multimedia keys remapping";
|
|
|
|
|
languages = [ "eng" ];
|
|
|
|
|
symbolsFile = /path/to/media-key;
|
|
|
|
|
keycodesFile = /path/to/media-sym;
|
|
|
|
|
};
|
|
|
|
|
</programlisting>
|
|
|
|
|
<note>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
<para>
|
|
|
|
|
The function <literal>pkgs.writeText <filename> <content>
|
|
|
|
|
</literal> can be useful if you prefer to keep the layout definitions
|
|
|
|
|
inside the NixOS configuration.
|
|
|
|
|
</para>
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</note>
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
Unfortunately, the Xorg server does not (currently) support setting a
|
|
|
|
|
keymap directly but relies instead on XKB rules to select the matching
|
|
|
|
|
components (keycodes, types, ...) of a layout. This means that components
|
|
|
|
|
other than symbols won't be loaded by default. As a workaround, you
|
|
|
|
|
can set the keymap using <literal>setxkbmap</literal> at the start of the
|
|
|
|
|
session with:
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
<xref linkend="opt-services.xserver.displayManager.sessionCommands"/> = "setxkbmap -keycodes media";
|
|
|
|
|
</programlisting>
|
2019-09-08 13:57:52 +01:00
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
If you are manually starting the X server, you should set the argument
|
|
|
|
|
<literal>-xkbdir /etc/X11/xkb</literal>, otherwise X won't find your layout files.
|
|
|
|
|
For example with <command>xinit</command> run
|
|
|
|
|
<screen><prompt>$ </prompt>xinit -- -xkbdir /etc/X11/xkb</screen>
|
2019-09-08 13:57:52 +01:00
|
|
|
|
</para>
|
2019-07-22 09:06:20 +01:00
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
To learn how to write layouts take a look at the XKB
|
|
|
|
|
<link xlink:href="https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Enhancing.html#Defining_New_Layouts">
|
|
|
|
|
documentation
|
|
|
|
|
</link>. More example layouts can also be found
|
|
|
|
|
<link xlink:href="https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Basic_examples">
|
|
|
|
|
here
|
|
|
|
|
</link>.
|
2019-07-22 09:06:20 +01:00
|
|
|
|
</para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
</simplesect>
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</chapter>
|