2014-04-14 16:26:48 +02:00
|
|
|
|
{ config, lib, pkgs, pkgs_i686, ... }:
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
|
with lib;
|
2009-05-24 20:28:30 +02:00
|
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
|
let
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
kernelPackages = config.boot.kernelPackages;
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
2008-01-04 11:54:33 +01:00
|
|
|
|
# Abbreviations.
|
|
|
|
|
cfg = config.services.xserver;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
xorg = pkgs.xorg;
|
|
|
|
|
|
2008-01-04 11:54:33 +01:00
|
|
|
|
|
2014-04-29 14:16:34 +02:00
|
|
|
|
# Map video driver names to driver packages. FIXME: move into card-specific modules.
|
2008-10-10 18:45:56 +02:00
|
|
|
|
knownVideoDrivers = {
|
2016-03-29 16:57:24 +02:00
|
|
|
|
virtualbox = { modules = [ kernelPackages.virtualboxGuestAdditions ]; driverName = "vboxvideo"; };
|
2016-08-05 18:29:02 +02:00
|
|
|
|
|
|
|
|
|
# modesetting does not have a xf86videomodesetting package as it is included in xorgserver
|
|
|
|
|
modesetting = {};
|
2008-10-10 18:45:56 +02:00
|
|
|
|
};
|
|
|
|
|
|
2008-08-27 12:00:49 +02:00
|
|
|
|
fontsForXServer =
|
2009-09-10 14:37:33 +02:00
|
|
|
|
config.fonts.fonts ++
|
2008-08-27 12:00:49 +02:00
|
|
|
|
# We don't want these fonts in fonts.conf, because then modern,
|
|
|
|
|
# fontconfig-based applications will get horrible bitmapped
|
|
|
|
|
# Helvetica fonts. It's better to get a substitution (like Nimbus
|
|
|
|
|
# Sans) than that horror. But we do need the Adobe fonts for some
|
|
|
|
|
# old non-fontconfig applications. (Possibly this could be done
|
|
|
|
|
# better using a fontconfig rule.)
|
|
|
|
|
[ pkgs.xorg.fontadobe100dpi
|
|
|
|
|
pkgs.xorg.fontadobe75dpi
|
|
|
|
|
];
|
2009-06-26 01:29:49 +02:00
|
|
|
|
|
2013-01-24 13:06:32 +01:00
|
|
|
|
|
2013-01-10 00:31:08 +01:00
|
|
|
|
# Just enumerate all heads without discarding XRandR output information.
|
|
|
|
|
xrandrHeads = let
|
|
|
|
|
mkHead = num: output: {
|
|
|
|
|
name = "multihead${toString num}";
|
|
|
|
|
inherit output;
|
|
|
|
|
};
|
|
|
|
|
in imap mkHead cfg.xrandrHeads;
|
|
|
|
|
|
2015-04-18 20:04:03 +02:00
|
|
|
|
xrandrDeviceSection = let
|
|
|
|
|
monitors = flip map xrandrHeads (h: ''
|
|
|
|
|
Option "monitor-${h.output}" "${h.name}"
|
|
|
|
|
'');
|
|
|
|
|
# First option is indented through the space in the config but any
|
|
|
|
|
# subsequent options aren't so we need to apply indentation to
|
|
|
|
|
# them here
|
|
|
|
|
monitorsIndented = if length monitors > 1
|
|
|
|
|
then singleton (head monitors) ++ map (m: " " + m) (tail monitors)
|
|
|
|
|
else monitors;
|
|
|
|
|
in concatStrings monitorsIndented;
|
2013-01-10 00:31:08 +01:00
|
|
|
|
|
|
|
|
|
# Here we chain every monitor from the left to right, so we have:
|
|
|
|
|
# m4 right of m3 right of m2 right of m1 .----.----.----.----.
|
|
|
|
|
# Which will end up in reverse ----------> | m1 | m2 | m3 | m4 |
|
|
|
|
|
# `----^----^----^----'
|
|
|
|
|
xrandrMonitorSections = let
|
2015-04-18 19:34:28 +02:00
|
|
|
|
mkMonitor = previous: current: singleton {
|
2013-01-10 00:31:08 +01:00
|
|
|
|
inherit (current) name;
|
|
|
|
|
value = ''
|
|
|
|
|
Section "Monitor"
|
|
|
|
|
Identifier "${current.name}"
|
|
|
|
|
${optionalString (previous != []) ''
|
|
|
|
|
Option "RightOf" "${(head previous).name}"
|
|
|
|
|
''}
|
|
|
|
|
EndSection
|
|
|
|
|
'';
|
2015-04-18 19:34:28 +02:00
|
|
|
|
} ++ previous;
|
|
|
|
|
monitors = reverseList (foldl mkMonitor [] xrandrHeads);
|
2013-01-10 00:31:08 +01:00
|
|
|
|
in concatMapStrings (getAttr "value") monitors;
|
2009-06-26 01:29:49 +02:00
|
|
|
|
|
2016-09-27 15:26:37 +02:00
|
|
|
|
configFile = pkgs.runCommand "xserver.conf"
|
|
|
|
|
{ xfs = optionalString (cfg.useXFS != false)
|
|
|
|
|
''FontPath "${toString cfg.useXFS}"'';
|
|
|
|
|
inherit (cfg) config;
|
|
|
|
|
}
|
2009-09-10 14:37:33 +02:00
|
|
|
|
''
|
|
|
|
|
echo 'Section "Files"' >> $out
|
|
|
|
|
echo $xfs >> $out
|
|
|
|
|
|
|
|
|
|
for i in ${toString fontsForXServer}; do
|
|
|
|
|
if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then
|
|
|
|
|
for j in $(find $i -name fonts.dir); do
|
|
|
|
|
echo " FontPath \"$(dirname $j)\"" >> $out
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
done
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
for i in $(find ${toString cfg.modules} -type d); do
|
|
|
|
|
if test $(echo $i/*.so* | wc -w) -ne 0; then
|
|
|
|
|
echo " ModulePath \"$i\"" >> $out
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo 'EndSection' >> $out
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
echo "$config" >> $out
|
|
|
|
|
''; # */
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
|
in
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
{
|
2009-05-15 09:51:51 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
imports =
|
|
|
|
|
[ ./display-managers/default.nix
|
|
|
|
|
./window-managers/default.nix
|
|
|
|
|
./desktop-managers/default.nix
|
|
|
|
|
];
|
2009-05-15 09:51:51 +02:00
|
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
###### interface
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
services.xserver = {
|
|
|
|
|
|
|
|
|
|
enable = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.bool;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to enable the X server.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
autorun = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.bool;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to start the X server automatically.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
exportConfiguration = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.bool;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to symlink the X server configuration under
|
|
|
|
|
<filename>/etc/X11/xorg.conf</filename>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
enableTCP = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.bool;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to allow the X server to accept TCP connections.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-02 17:07:39 +01:00
|
|
|
|
|
2016-10-01 21:44:58 +02:00
|
|
|
|
autoRepeatDelay = mkOption {
|
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Sets the autorepeat delay (length of time in milliseconds that a key must be depressed before autorepeat starts).
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
autoRepeatInterval = mkOption {
|
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Sets the autorepeat interval (length of time in milliseconds that should elapse between autorepeat-generated keystrokes).
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-12 23:49:48 +02:00
|
|
|
|
inputClassSections = mkOption {
|
|
|
|
|
type = types.listOf types.lines;
|
|
|
|
|
default = [];
|
2015-07-04 08:52:50 +02:00
|
|
|
|
example = literalExample ''
|
|
|
|
|
[ '''
|
|
|
|
|
Identifier "Trackpoint Wheel Emulation"
|
|
|
|
|
MatchProduct "ThinkPad USB Keyboard with TrackPoint"
|
2016-03-18 10:25:37 +01:00
|
|
|
|
Option "EmulateWheel" "true"
|
2015-07-04 08:52:50 +02:00
|
|
|
|
Option "EmulateWheelButton" "2"
|
|
|
|
|
Option "Emulate3Buttons" "false"
|
|
|
|
|
'''
|
|
|
|
|
]
|
|
|
|
|
'';
|
2015-04-12 23:49:48 +02:00
|
|
|
|
description = "Content of additional InputClass sections of the X server configuration file.";
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
modules = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.listOf types.path;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = [];
|
2014-08-27 23:41:15 +02:00
|
|
|
|
example = literalExample "[ pkgs.xf86_input_wacom ]";
|
2009-09-10 14:37:33 +02:00
|
|
|
|
description = "Packages to be added to the module search path of the X server.";
|
|
|
|
|
};
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
resolutions = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.listOf types.attrs;
|
2009-11-06 01:59:03 +01:00
|
|
|
|
default = [];
|
2010-08-09 22:10:16 +02:00
|
|
|
|
example = [ { x = 1600; y = 1200; } { x = 1024; y = 786; } ];
|
2009-09-10 14:37:33 +02:00
|
|
|
|
description = ''
|
2009-11-06 01:59:03 +01:00
|
|
|
|
The screen resolutions for the X server. The first element
|
|
|
|
|
is the default resolution. If this list is empty, the X
|
|
|
|
|
server will automatically configure the resolution.
|
2009-09-10 14:37:33 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
2014-04-29 12:58:54 +02:00
|
|
|
|
videoDrivers = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
# !!! We'd like "nv" here, but it segfaults the X server.
|
2014-05-21 15:40:48 +02:00
|
|
|
|
default = [ "ati" "cirrus" "intel" "vesa" "vmware" "modesetting" ];
|
2014-04-29 12:58:54 +02:00
|
|
|
|
example = [ "vesa" ];
|
|
|
|
|
description = ''
|
|
|
|
|
The names of the video drivers the configuration
|
|
|
|
|
supports. They will be tried in order until one that
|
|
|
|
|
supports your card is found.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
videoDriver = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.nullOr types.str;
|
2009-11-06 01:59:03 +01:00
|
|
|
|
default = null;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
example = "i810";
|
|
|
|
|
description = ''
|
2009-11-06 01:59:03 +01:00
|
|
|
|
The name of the video driver for your graphics card. This
|
|
|
|
|
option is obsolete; please set the
|
2014-04-29 12:58:54 +02:00
|
|
|
|
<option>services.xserver.videoDrivers</option> instead.
|
2009-09-10 14:37:33 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
2014-04-29 14:16:34 +02:00
|
|
|
|
drivers = mkOption {
|
|
|
|
|
type = types.listOf types.attrs;
|
|
|
|
|
internal = true;
|
|
|
|
|
description = ''
|
|
|
|
|
A list of attribute sets specifying drivers to be loaded by
|
|
|
|
|
the X11 server.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-09 03:53:42 +02:00
|
|
|
|
dpi = mkOption {
|
|
|
|
|
type = types.nullOr types.int;
|
2016-04-10 17:46:17 +02:00
|
|
|
|
default = null;
|
2016-04-09 03:53:42 +02:00
|
|
|
|
description = "DPI resolution to use for X server.";
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-22 18:08:29 +02:00
|
|
|
|
startDbusSession = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to start a new DBus session when you log in with dbus-launch.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-25 23:37:18 +02:00
|
|
|
|
updateDbusEnvironment = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to update the DBus activation environment after launching the
|
|
|
|
|
desktop manager.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
layout = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.str;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "us";
|
|
|
|
|
description = ''
|
|
|
|
|
Keyboard layout.
|
|
|
|
|
'';
|
2009-01-25 16:49:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
xkbModel = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.str;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "pc104";
|
|
|
|
|
example = "presario";
|
|
|
|
|
description = ''
|
|
|
|
|
Keyboard model.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-06-26 01:29:49 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
xkbOptions = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.str;
|
2010-08-10 14:37:39 +02:00
|
|
|
|
default = "terminate:ctrl_alt_bksp";
|
2009-09-10 14:37:33 +02:00
|
|
|
|
example = "grp:caps_toggle, grp_led:scroll";
|
|
|
|
|
description = ''
|
|
|
|
|
X keyboard options; layout switching goes here.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
2011-12-31 00:26:11 +01:00
|
|
|
|
xkbVariant = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.str;
|
2011-12-31 00:26:11 +01:00
|
|
|
|
default = "";
|
|
|
|
|
example = "colemak";
|
|
|
|
|
description = ''
|
|
|
|
|
X keyboard variant.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-24 13:30:42 +01:00
|
|
|
|
xkbDir = mkOption {
|
2015-12-26 09:06:28 +01:00
|
|
|
|
type = types.path;
|
2015-12-24 13:30:42 +01:00
|
|
|
|
description = ''
|
2015-12-26 09:06:28 +01:00
|
|
|
|
Path used for -xkbdir xserver parameter.
|
2015-12-24 13:30:42 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
config = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
description = ''
|
|
|
|
|
The contents of the configuration file of the X server
|
|
|
|
|
(<filename>xorg.conf</filename>).
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-06-03 10:14:54 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
deviceSection = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example = "VideoRAM 131072";
|
|
|
|
|
description = "Contents of the first Device section of the X server configuration file.";
|
|
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
2010-05-08 19:18:22 +02:00
|
|
|
|
screenSection = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2010-05-08 19:18:22 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example = ''
|
|
|
|
|
Option "RandRRotation" "on"
|
|
|
|
|
'';
|
|
|
|
|
description = "Contents of the first Screen section of the X server configuration file.";
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
monitorSection = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example = "HorizSync 28-49";
|
|
|
|
|
description = "Contents of the first Monitor section of the X server configuration file.";
|
|
|
|
|
};
|
2009-04-08 15:41:33 +02:00
|
|
|
|
|
2013-01-10 00:31:08 +01:00
|
|
|
|
xrandrHeads = mkOption {
|
|
|
|
|
default = [];
|
|
|
|
|
example = [ "HDMI-0" "DVI-0" ];
|
|
|
|
|
type = with types; listOf string;
|
|
|
|
|
description = ''
|
|
|
|
|
Simple multiple monitor configuration, just specify a list of XRandR
|
|
|
|
|
outputs which will be mapped from left to right in the order of the
|
|
|
|
|
list.
|
|
|
|
|
|
|
|
|
|
Be careful using this option with multiple graphic adapters or with
|
|
|
|
|
drivers that have poor support for XRandR, unexpected things might
|
|
|
|
|
happen with those.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-04 15:45:05 +01:00
|
|
|
|
serverFlagsSection = mkOption {
|
|
|
|
|
default = "";
|
|
|
|
|
example =
|
|
|
|
|
''
|
|
|
|
|
Option "BlankTime" "0"
|
|
|
|
|
Option "StandbyTime" "0"
|
|
|
|
|
Option "SuspendTime" "0"
|
|
|
|
|
Option "OffTime" "0"
|
|
|
|
|
'';
|
|
|
|
|
description = "Contents of the ServerFlags section of the X server configuration file.";
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
moduleSection = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example =
|
|
|
|
|
''
|
|
|
|
|
SubSection "extmod"
|
|
|
|
|
EndSubsection
|
|
|
|
|
'';
|
|
|
|
|
description = "Contents of the Module section of the X server configuration file.";
|
|
|
|
|
};
|
2009-04-08 15:41:33 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
serverLayoutSection = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example =
|
|
|
|
|
''
|
|
|
|
|
Option "AIGLX" "true"
|
|
|
|
|
'';
|
|
|
|
|
description = "Contents of the ServerLayout section of the X server configuration file.";
|
|
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
extraDisplaySettings = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.lines;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = "";
|
|
|
|
|
example = "Virtual 2048 2048";
|
|
|
|
|
description = "Lines to be added to every Display subsection of the Screen section.";
|
|
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
defaultDepth = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.int;
|
2009-11-06 01:59:03 +01:00
|
|
|
|
default = 0;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
example = 8;
|
|
|
|
|
description = "Default colour depth.";
|
|
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
useXFS = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
# FIXME: what's the type of this option?
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = false;
|
|
|
|
|
example = "unix/:7100";
|
|
|
|
|
description = "Determines how to connect to the X Font Server.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tty = mkOption {
|
2015-11-29 01:18:59 +01:00
|
|
|
|
type = types.nullOr types.int;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = 7;
|
|
|
|
|
description = "Virtual console for the X server.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
display = mkOption {
|
2015-11-29 01:18:59 +01:00
|
|
|
|
type = types.nullOr types.int;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = 0;
|
|
|
|
|
description = "Display number for the X server.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
virtualScreen = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.nullOr types.attrs;
|
2009-09-10 14:37:33 +02:00
|
|
|
|
default = null;
|
|
|
|
|
example = { x = 2048; y = 2048; };
|
|
|
|
|
description = ''
|
|
|
|
|
Virtual screen size for Xrandr.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2014-03-16 18:46:20 +01:00
|
|
|
|
useGlamor = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to use the Glamor module for 2D acceleration,
|
|
|
|
|
if possible.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2015-11-23 15:45:26 +01:00
|
|
|
|
|
|
|
|
|
enableCtrlAltBackspace = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to enable the DontZap option, which binds Ctrl+Alt+Backspace
|
|
|
|
|
to forcefully kill X. This can lead to data loss and is disabled
|
|
|
|
|
by default.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2009-09-10 14:37:33 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2013-05-16 17:23:31 +02:00
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
###### implementation
|
2009-11-21 23:14:01 +01:00
|
|
|
|
|
2013-10-30 18:30:23 +01:00
|
|
|
|
config = mkIf cfg.enable {
|
2014-04-29 14:16:34 +02:00
|
|
|
|
|
|
|
|
|
hardware.opengl.enable = mkDefault true;
|
|
|
|
|
|
2014-04-29 12:58:54 +02:00
|
|
|
|
services.xserver.videoDrivers = mkIf (cfg.videoDriver != null) [ cfg.videoDriver ];
|
2013-10-30 18:30:23 +01:00
|
|
|
|
|
2016-08-06 07:22:33 +02:00
|
|
|
|
# FIXME: somehow check for unknown driver names.
|
|
|
|
|
services.xserver.drivers = flip concatMap cfg.videoDrivers (name:
|
2014-04-29 14:16:34 +02:00
|
|
|
|
let driver =
|
|
|
|
|
attrByPath [name]
|
2014-10-05 00:03:52 +02:00
|
|
|
|
(if xorg ? ${"xf86video" + name}
|
|
|
|
|
then { modules = [xorg.${"xf86video" + name}]; }
|
2016-08-06 07:22:33 +02:00
|
|
|
|
else null)
|
2014-04-29 14:16:34 +02:00
|
|
|
|
knownVideoDrivers;
|
2016-08-06 07:22:33 +02:00
|
|
|
|
in optional (driver != null) ({ inherit name; modules = []; driverName = name; } // driver));
|
2014-04-29 14:16:34 +02:00
|
|
|
|
|
2013-10-30 18:30:23 +01:00
|
|
|
|
assertions =
|
2016-03-18 10:31:40 +01:00
|
|
|
|
[ { assertion = config.security.polkit.enable;
|
2013-10-30 18:30:23 +01:00
|
|
|
|
message = "X11 requires Polkit to be enabled (‘security.polkit.enable = true’).";
|
|
|
|
|
}
|
|
|
|
|
];
|
2009-09-10 14:37:33 +02:00
|
|
|
|
|
2012-10-07 17:24:42 +02:00
|
|
|
|
environment.etc =
|
2013-08-09 18:45:45 +02:00
|
|
|
|
(optionals cfg.exportConfiguration
|
|
|
|
|
[ { source = "${configFile}";
|
|
|
|
|
target = "X11/xorg.conf";
|
|
|
|
|
}
|
|
|
|
|
# -xkbdir command line option does not seems to be passed to xkbcomp.
|
2015-12-24 13:30:42 +01:00
|
|
|
|
{ source = "${cfg.xkbDir}";
|
2013-08-09 18:45:45 +02:00
|
|
|
|
target = "X11/xkb";
|
|
|
|
|
}
|
2016-05-23 13:01:01 +02:00
|
|
|
|
])
|
|
|
|
|
# Needed since 1.18; see https://bugs.freedesktop.org/show_bug.cgi?id=89023#c5
|
|
|
|
|
++ (let cfgPath = "/X11/xorg.conf.d/10-evdev.conf"; in
|
|
|
|
|
[{
|
|
|
|
|
source = xorg.xf86inputevdev.out + "/share" + cfgPath;
|
|
|
|
|
target = cfgPath;
|
|
|
|
|
}]
|
|
|
|
|
);
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2013-10-30 17:52:35 +01:00
|
|
|
|
environment.systemPackages =
|
2015-11-25 09:47:56 +01:00
|
|
|
|
[ xorg.xorgserver.out
|
2009-09-10 14:37:33 +02:00
|
|
|
|
xorg.xrandr
|
|
|
|
|
xorg.xrdb
|
|
|
|
|
xorg.setxkbmap
|
|
|
|
|
xorg.iceauth # required for KDE applications (it's called by dcopserver)
|
2010-02-10 14:22:38 +01:00
|
|
|
|
xorg.xlsclients
|
|
|
|
|
xorg.xset
|
2009-09-10 14:37:33 +02:00
|
|
|
|
xorg.xsetroot
|
2013-04-27 03:30:40 +02:00
|
|
|
|
xorg.xinput
|
2009-09-13 15:26:35 +02:00
|
|
|
|
xorg.xprop
|
2016-04-12 19:12:47 +02:00
|
|
|
|
xorg.xauth
|
2010-02-10 14:22:38 +01:00
|
|
|
|
pkgs.xterm
|
2012-05-15 04:49:47 +02:00
|
|
|
|
pkgs.xdg_utils
|
2016-05-23 13:01:01 +02:00
|
|
|
|
xorg.xf86inputevdev.out # get evdev.4 man page
|
2009-09-10 14:37:33 +02:00
|
|
|
|
]
|
2014-09-05 11:53:36 +02:00
|
|
|
|
++ optional (elem "virtualbox" cfg.videoDrivers) xorg.xrefresh;
|
2014-03-17 19:27:06 +01:00
|
|
|
|
|
2010-08-09 20:04:55 +02:00
|
|
|
|
environment.pathsToLink =
|
|
|
|
|
[ "/etc/xdg" "/share/xdg" "/share/applications" "/share/icons" "/share/pixmaps" ];
|
2011-03-30 19:52:34 +02:00
|
|
|
|
|
2015-06-12 13:02:06 +02:00
|
|
|
|
# The default max inotify watches is 8192.
|
|
|
|
|
# Nowadays most apps require a good number of inotify watches,
|
|
|
|
|
# the value below is used by default on several other distros.
|
|
|
|
|
boot.kernel.sysctl."fs.inotify.max_user_watches" = mkDefault 524288;
|
|
|
|
|
|
2013-01-16 12:33:18 +01:00
|
|
|
|
systemd.defaultUnit = mkIf cfg.autorun "graphical.target";
|
2012-06-19 20:51:04 +02:00
|
|
|
|
|
2014-04-29 14:16:34 +02:00
|
|
|
|
systemd.services.display-manager =
|
2013-01-10 13:59:41 +01:00
|
|
|
|
{ description = "X11 Server";
|
|
|
|
|
|
2016-01-13 15:16:51 +01:00
|
|
|
|
after = [ "systemd-udev-settle.service" "local-fs.target" "acpid.service" "systemd-logind.service" ];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2012-08-17 19:14:42 +02:00
|
|
|
|
restartIfChanged = false;
|
2012-03-18 03:10:39 +01:00
|
|
|
|
|
|
|
|
|
environment =
|
2014-09-28 15:11:10 +02:00
|
|
|
|
{
|
2013-05-16 17:23:31 +02:00
|
|
|
|
XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime.
|
2014-04-29 14:16:34 +02:00
|
|
|
|
LD_LIBRARY_PATH = concatStringsSep ":" (
|
2016-07-30 10:40:30 +02:00
|
|
|
|
[ "${xorg.libX11.out}/lib" "${xorg.libXext.out}/lib" "/run/opengl-driver/lib" ]
|
2014-04-29 14:16:34 +02:00
|
|
|
|
++ concatLists (catAttrs "libPath" cfg.drivers));
|
2009-09-10 14:37:33 +02:00
|
|
|
|
} // cfg.displayManager.job.environment;
|
|
|
|
|
|
|
|
|
|
preStart =
|
|
|
|
|
''
|
2009-09-10 17:49:16 +02:00
|
|
|
|
${cfg.displayManager.job.preStart}
|
2009-09-10 14:37:33 +02:00
|
|
|
|
|
|
|
|
|
rm -f /tmp/.X0-lock
|
|
|
|
|
'';
|
|
|
|
|
|
2009-09-13 17:03:07 +02:00
|
|
|
|
script = "${cfg.displayManager.job.execCmd}";
|
2013-10-15 13:15:33 +02:00
|
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Restart = "always";
|
|
|
|
|
RestartSec = "200ms";
|
2016-05-24 21:07:26 +02:00
|
|
|
|
SyslogIdentifier = "display-manager";
|
2016-10-10 22:35:37 +02:00
|
|
|
|
# Stop restarting if the display manager stops (crashes) 2 times
|
|
|
|
|
# in one minute. Starting X typically takes 3-4s.
|
|
|
|
|
StartLimitInterval = "30s";
|
|
|
|
|
StartLimitBurst = "3";
|
2013-10-15 13:15:33 +02:00
|
|
|
|
};
|
2009-09-10 14:37:33 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.xserver.displayManager.xserverArgs =
|
2016-04-12 18:37:53 +02:00
|
|
|
|
[ "-terminate"
|
2009-09-10 14:37:33 +02:00
|
|
|
|
"-config ${configFile}"
|
2015-12-24 13:30:42 +01:00
|
|
|
|
"-xkbdir" "${cfg.xkbDir}"
|
2016-05-24 21:07:26 +02:00
|
|
|
|
# Log at the default verbosity level to stderr rather than /var/log/X.*.log.
|
|
|
|
|
"-verbose" "3" "-logfile" "/dev/null"
|
2015-12-16 17:22:19 +01:00
|
|
|
|
] ++ optional (cfg.display != null) ":${toString cfg.display}"
|
2015-11-29 01:18:59 +01:00
|
|
|
|
++ optional (cfg.tty != null) "vt${toString cfg.tty}"
|
2016-04-09 03:53:42 +02:00
|
|
|
|
++ optional (cfg.dpi != null) "-dpi ${toString cfg.dpi}"
|
2016-10-01 21:44:58 +02:00
|
|
|
|
++ optional (!cfg.enableTCP) "-nolisten tcp"
|
|
|
|
|
++ optional (cfg.autoRepeatDelay != null) "-ardelay ${toString cfg.autoRepeatDelay}"
|
|
|
|
|
++ optional (cfg.autoRepeatInterval != null) "-arinterval ${toString cfg.autoRepeatInterval}";
|
2009-09-10 14:37:33 +02:00
|
|
|
|
|
2009-11-06 01:59:03 +01:00
|
|
|
|
services.xserver.modules =
|
2014-04-29 14:16:34 +02:00
|
|
|
|
concatLists (catAttrs "modules" cfg.drivers) ++
|
2015-11-25 09:47:56 +01:00
|
|
|
|
[ xorg.xorgserver.out
|
2016-05-23 13:00:21 +02:00
|
|
|
|
xorg.xf86inputevdev.out
|
2009-11-06 01:59:03 +01:00
|
|
|
|
];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2015-12-26 09:06:28 +01:00
|
|
|
|
services.xserver.xkbDir = mkDefault "${pkgs.xkeyboard_config}/etc/X11/xkb";
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
services.xserver.config =
|
|
|
|
|
''
|
|
|
|
|
Section "ServerFlags"
|
|
|
|
|
Option "AllowMouseOpenFail" "on"
|
2015-11-23 15:45:26 +01:00
|
|
|
|
Option "DontZap" "${if cfg.enableCtrlAltBackspace then "off" else "on"}"
|
2013-11-04 15:45:05 +01:00
|
|
|
|
${cfg.serverFlagsSection}
|
2009-09-10 14:37:33 +02:00
|
|
|
|
EndSection
|
|
|
|
|
|
|
|
|
|
Section "Module"
|
|
|
|
|
${cfg.moduleSection}
|
|
|
|
|
EndSection
|
|
|
|
|
|
|
|
|
|
Section "Monitor"
|
2009-11-06 01:59:03 +01:00
|
|
|
|
Identifier "Monitor[0]"
|
2009-09-10 14:37:33 +02:00
|
|
|
|
${cfg.monitorSection}
|
|
|
|
|
EndSection
|
|
|
|
|
|
2010-08-02 21:06:42 +02:00
|
|
|
|
Section "InputClass"
|
2010-08-10 16:13:57 +02:00
|
|
|
|
Identifier "Keyboard catchall"
|
2010-08-02 21:06:42 +02:00
|
|
|
|
MatchIsKeyboard "on"
|
|
|
|
|
Option "XkbRules" "base"
|
|
|
|
|
Option "XkbModel" "${cfg.xkbModel}"
|
|
|
|
|
Option "XkbLayout" "${cfg.layout}"
|
|
|
|
|
Option "XkbOptions" "${cfg.xkbOptions}"
|
2011-12-31 00:26:11 +01:00
|
|
|
|
Option "XkbVariant" "${cfg.xkbVariant}"
|
2010-08-02 21:06:42 +02:00
|
|
|
|
EndSection
|
|
|
|
|
|
2015-04-18 19:52:15 +02:00
|
|
|
|
# Additional "InputClass" sections
|
2015-04-12 23:49:48 +02:00
|
|
|
|
${flip concatMapStrings cfg.inputClassSections (inputClassSection: ''
|
|
|
|
|
Section "InputClass"
|
|
|
|
|
${inputClassSection}
|
|
|
|
|
EndSection
|
|
|
|
|
'')}
|
|
|
|
|
|
|
|
|
|
|
2009-09-10 14:37:33 +02:00
|
|
|
|
Section "ServerLayout"
|
2009-11-06 01:59:03 +01:00
|
|
|
|
Identifier "Layout[all]"
|
2009-09-10 14:37:33 +02:00
|
|
|
|
${cfg.serverLayoutSection}
|
2009-11-06 01:59:03 +01:00
|
|
|
|
# Reference the Screen sections for each driver. This will
|
|
|
|
|
# cause the X server to try each in turn.
|
2014-04-29 14:16:34 +02:00
|
|
|
|
${flip concatMapStrings cfg.drivers (d: ''
|
2009-11-06 01:59:03 +01:00
|
|
|
|
Screen "Screen-${d.name}[0]"
|
|
|
|
|
'')}
|
2009-09-10 14:37:33 +02:00
|
|
|
|
EndSection
|
|
|
|
|
|
2014-03-16 18:46:20 +01:00
|
|
|
|
${if cfg.useGlamor then ''
|
|
|
|
|
Section "Module"
|
|
|
|
|
Load "dri2"
|
|
|
|
|
Load "glamoregl"
|
|
|
|
|
EndSection
|
|
|
|
|
'' else ""}
|
|
|
|
|
|
2009-11-06 01:59:03 +01:00
|
|
|
|
# For each supported driver, add a "Device" and "Screen"
|
|
|
|
|
# section.
|
2014-04-29 14:16:34 +02:00
|
|
|
|
${flip concatMapStrings cfg.drivers (driver: ''
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-11-06 01:59:03 +01:00
|
|
|
|
Section "Device"
|
|
|
|
|
Identifier "Device-${driver.name}[0]"
|
2014-04-29 14:16:34 +02:00
|
|
|
|
Driver "${driver.driverName or driver.name}"
|
2014-03-16 18:46:20 +01:00
|
|
|
|
${if cfg.useGlamor then ''Option "AccelMethod" "glamor"'' else ""}
|
2009-11-06 01:59:03 +01:00
|
|
|
|
${cfg.deviceSection}
|
2013-01-10 00:31:08 +01:00
|
|
|
|
${xrandrDeviceSection}
|
2009-11-06 01:59:03 +01:00
|
|
|
|
EndSection
|
|
|
|
|
|
|
|
|
|
Section "Screen"
|
|
|
|
|
Identifier "Screen-${driver.name}[0]"
|
|
|
|
|
Device "Device-${driver.name}[0]"
|
2010-08-09 22:10:16 +02:00
|
|
|
|
${optionalString (cfg.monitorSection != "") ''
|
|
|
|
|
Monitor "Monitor[0]"
|
|
|
|
|
''}
|
2009-11-06 01:59:03 +01:00
|
|
|
|
|
2010-05-08 19:18:22 +02:00
|
|
|
|
${cfg.screenSection}
|
|
|
|
|
|
2009-11-06 01:59:03 +01:00
|
|
|
|
${optionalString (cfg.defaultDepth != 0) ''
|
|
|
|
|
DefaultDepth ${toString cfg.defaultDepth}
|
|
|
|
|
''}
|
|
|
|
|
|
|
|
|
|
${optionalString
|
2010-08-09 22:10:16 +02:00
|
|
|
|
(driver.name != "virtualbox" &&
|
|
|
|
|
(cfg.resolutions != [] ||
|
|
|
|
|
cfg.extraDisplaySettings != "" ||
|
|
|
|
|
cfg.virtualScreen != null))
|
|
|
|
|
(let
|
2009-11-06 01:59:03 +01:00
|
|
|
|
f = depth:
|
|
|
|
|
''
|
|
|
|
|
SubSection "Display"
|
|
|
|
|
Depth ${toString depth}
|
|
|
|
|
${optionalString (cfg.resolutions != [])
|
|
|
|
|
"Modes ${concatMapStrings (res: ''"${toString res.x}x${toString res.y}"'') cfg.resolutions}"}
|
|
|
|
|
${cfg.extraDisplaySettings}
|
|
|
|
|
${optionalString (cfg.virtualScreen != null)
|
|
|
|
|
"Virtual ${toString cfg.virtualScreen.x} ${toString cfg.virtualScreen.y}"}
|
|
|
|
|
EndSubSection
|
|
|
|
|
'';
|
|
|
|
|
in concatMapStrings f [8 16 24]
|
|
|
|
|
)}
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
2009-11-06 01:59:03 +01:00
|
|
|
|
EndSection
|
|
|
|
|
'')}
|
2013-01-09 22:19:58 +01:00
|
|
|
|
|
2013-01-10 00:31:08 +01:00
|
|
|
|
${xrandrMonitorSections}
|
2009-09-10 14:37:33 +02:00
|
|
|
|
'';
|
|
|
|
|
|
2016-09-05 15:48:48 +02:00
|
|
|
|
fonts.enableDefaultFonts = mkDefault true;
|
|
|
|
|
|
2013-10-30 18:30:23 +01:00
|
|
|
|
};
|
2009-09-10 14:37:33 +02:00
|
|
|
|
|
2006-11-28 23:27:56 +01:00
|
|
|
|
}
|