2009-01-02 17:07:21 +01:00
|
|
|
{config, pkgs, ...}:
|
|
|
|
# TODO: this file need some make-up (Nicolas Pierron)
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
let
|
|
|
|
kernelPackages = config.boot.kernelPackages;
|
|
|
|
# List of font directories.
|
2009-01-02 17:07:39 +01:00
|
|
|
fontDirectories = config.fonts.fonts;
|
2009-01-02 17:07:21 +01:00
|
|
|
|
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
|
|
|
|
xserver = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable the X server.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
autorun = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Switch to false to create upstart-job and configuration,
|
|
|
|
but not run it automatically
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
exportConfiguration = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Create /etc/X11/xorg.conf and a file with environment
|
|
|
|
variables
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
tcpEnable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable TCP socket for the X server.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
resolutions = mkOption {
|
|
|
|
default = [{x = 1024; y = 768;} {x = 800; y = 600;} {x = 640; y = 480;}];
|
|
|
|
description = "
|
|
|
|
The screen resolutions for the X server. The first element is the default resolution.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
videoDriver = mkOption {
|
|
|
|
default = "vesa";
|
|
|
|
example = "i810";
|
|
|
|
description = "
|
|
|
|
The name of the video driver for your graphics card.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
driSupport = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable accelerated OpenGL rendering through the
|
|
|
|
Direct Rendering Interface (DRI).
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
sessionType = mkOption {
|
|
|
|
default = "gnome";
|
|
|
|
example = "xterm";
|
|
|
|
description = "
|
|
|
|
The kind of session to start after login. Current possibilies
|
|
|
|
are <literal>kde</literal> (which starts KDE),
|
|
|
|
<literal>gnome</literal> (which starts
|
|
|
|
<command>gnome-terminal</command>) and <literal>xterm</literal>
|
|
|
|
(which starts <command>xterm</command>).
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
windowManager = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "
|
|
|
|
This option selects the window manager. Available values are
|
|
|
|
<literal>twm</literal> (extremely primitive),
|
|
|
|
<literal>metacity</literal>, <literal>xmonad</literal>
|
|
|
|
and <literal>compiz</literal>. If
|
|
|
|
left empty, the <option>sessionType</option> determines the
|
|
|
|
window manager, e.g., Metacity for Gnome, and
|
|
|
|
<command>kwm</command> for KDE.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
renderingFlag = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "--indirect-rendering";
|
|
|
|
description = "
|
|
|
|
Possibly pass --indierct-rendering to Compiz.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
sessionStarter = mkOption {
|
|
|
|
example = "${pkgs.xterm}/bin/xterm -ls";
|
|
|
|
description = "
|
|
|
|
The command executed after login and after the window manager
|
|
|
|
has been started. Used if
|
|
|
|
<option>services.xserver.sessionType</option> is empty.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
startSSHAgent = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether to start the SSH agent when you log in. The SSH agent
|
|
|
|
remembers private keys for you so that you don't have to type in
|
|
|
|
passphrases every time you make an SSH connection. Use
|
|
|
|
<command>ssh-add</command> to add a key to the agent.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
slim = {
|
|
|
|
|
|
|
|
theme = mkOption {
|
|
|
|
default = null;
|
|
|
|
example = pkgs.fetchurl {
|
|
|
|
url = http://download.berlios.de/slim/slim-wave.tar.gz;
|
|
|
|
sha256 = "0ndr419i5myzcylvxb89m9grl2xyq6fbnyc3lkd711mzlmnnfxdy";
|
|
|
|
};
|
|
|
|
description = "
|
|
|
|
The theme for the SLiM login manager. If not specified, SLiM's
|
|
|
|
default theme is used. See <link
|
|
|
|
xlink:href='http://slim.berlios.de/themes01.php'/> for a
|
|
|
|
collection of themes.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultUser = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "login";
|
|
|
|
description = "
|
|
|
|
The default user to load. If you put a username here you
|
|
|
|
get it automatically loaded into the username field, and
|
|
|
|
the focus is placed on the password.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
hideCursor = mkOption {
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
description = "
|
|
|
|
Hide the mouse cursor on the login screen.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
isClone = mkOption {
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable the X server clone mode for dual-head.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
synaptics = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
description = "
|
|
|
|
Whether to replace mouse with touchpad.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
dev = mkOption {
|
|
|
|
default = "/dev/input/event0";
|
|
|
|
description = "
|
|
|
|
Event device for Synaptics touchpad.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
minSpeed = mkOption {
|
|
|
|
default = "0.06";
|
|
|
|
description = "Cursor speed factor for precision finger motion";
|
|
|
|
};
|
|
|
|
maxSpeed = mkOption {
|
|
|
|
default = "0.12";
|
|
|
|
description = "Cursor speed factor for highest-speed finger motion";
|
|
|
|
};
|
2009-01-02 20:41:39 +01:00
|
|
|
twoFingerScroll = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable two-finger drag-scrolling";
|
|
|
|
};
|
2009-01-02 17:07:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
layout = mkOption {
|
|
|
|
default = "us";
|
|
|
|
description = "
|
|
|
|
Keyboard layout.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
xkbModel = mkOption {
|
|
|
|
default = "pc104";
|
|
|
|
example = "presario";
|
|
|
|
description = "
|
|
|
|
Keyboard model.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
xkbOptions = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "grp:caps_toggle, grp_led:scroll";
|
|
|
|
description = "
|
|
|
|
X keyboard options; layout switching goes here.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
useInternalAGPGART = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "no";
|
|
|
|
description = "
|
|
|
|
Just the wrapper for an xorg.conf option.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraDeviceConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "VideoRAM 131072";
|
|
|
|
description = "
|
|
|
|
Just anything to add into Device section.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraMonitorSettings = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "HorizSync 28-49";
|
|
|
|
description = "
|
|
|
|
Just anything to add into Monitor section.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraDisplaySettings = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "Virtual 2048 2048";
|
|
|
|
description = "
|
|
|
|
Just anything to add into Display subsection (located in Screen section).
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraModules = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "
|
|
|
|
SubSection \"extmod\"
|
|
|
|
EndSubsection
|
|
|
|
";
|
|
|
|
description = "
|
|
|
|
Just anything to add into Modules section.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
serverLayoutOptions = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = "
|
|
|
|
Option \"AIGLX\" \"true\"
|
|
|
|
";
|
|
|
|
description = "
|
|
|
|
Just anything to add into Monitor section.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultDepth = mkOption {
|
|
|
|
default = 24;
|
|
|
|
example = 8;
|
|
|
|
description = "
|
|
|
|
Default colour depth.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
useXFS = mkOption {
|
|
|
|
default = false;
|
|
|
|
example = "unix/:7100";
|
|
|
|
description = "
|
|
|
|
Way to access the X Font Server to use.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
tty = mkOption {
|
|
|
|
default = 7;
|
|
|
|
example = 9;
|
|
|
|
description = "
|
|
|
|
Virtual console for the X server.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
display = mkOption {
|
|
|
|
default = 0;
|
|
|
|
example = 1;
|
|
|
|
description = "
|
|
|
|
Display number for the X server.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.xorg;
|
|
|
|
description = "
|
|
|
|
Alternative X.org package to use. For
|
|
|
|
example, you can replace individual drivers.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualScreen = mkOption {
|
|
|
|
default = null;
|
|
|
|
example = {
|
|
|
|
x=2048;
|
|
|
|
y=2048;
|
|
|
|
};
|
|
|
|
description = "
|
|
|
|
Virtual screen size for Xrandr
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
inherit (pkgs.lib) optional isInList getAttr mkIf;
|
2008-01-04 11:54:33 +01:00
|
|
|
# Abbreviations.
|
|
|
|
cfg = config.services.xserver;
|
2008-08-08 20:57:11 +02:00
|
|
|
xorg = cfg.package;
|
2008-01-04 11:54:33 +01:00
|
|
|
gnome = pkgs.gnome;
|
2008-02-22 04:08:26 +01:00
|
|
|
stdenv = pkgs.stdenv;
|
2008-01-04 11:54:33 +01:00
|
|
|
|
2008-10-10 18:45:56 +02:00
|
|
|
knownVideoDrivers = {
|
|
|
|
nvidia = { modulesFirst = [ kernelPackages.nvidiaDrivers ]; }; #make sure it first loads the nvidia libs
|
|
|
|
vesa = { modules = [xorg.xf86videovesa]; };
|
|
|
|
vga = { modules = [xorg.xf86videovga]; };
|
|
|
|
sis = { modules = [xorg.xf86videosis]; };
|
|
|
|
i810 = { modules = [xorg.xf86videoi810]; };
|
|
|
|
intel = { modules = [xorg.xf86videointel]; };
|
|
|
|
nv = { modules = [xorg.xf86videonv]; };
|
|
|
|
ati = { modules = [xorg.xf86videoati]; };
|
|
|
|
};
|
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
# Get a bunch of user settings.
|
2007-11-09 19:49:45 +01:00
|
|
|
videoDriver = cfg.videoDriver;
|
2008-01-04 11:28:12 +01:00
|
|
|
resolutions = map (res: ''"${toString res.x}x${toString res.y}"'') (cfg.resolutions);
|
2007-11-09 19:49:45 +01:00
|
|
|
sessionType = cfg.sessionType;
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2008-10-10 18:45:56 +02:00
|
|
|
videoDriverModules = getAttr [ videoDriver ] (throw "unkown video driver : \"${videoDriver}\"") knownVideoDrivers;
|
2007-03-06 01:07:00 +01:00
|
|
|
|
|
|
|
sessionCmd =
|
2008-01-16 16:33:09 +01:00
|
|
|
if sessionType == "" then cfg.sessionStarter else
|
2008-01-04 11:54:33 +01:00
|
|
|
if sessionType == "xterm" then "${pkgs.xterm}/bin/xterm -ls" else
|
2007-05-28 16:09:04 +02:00
|
|
|
if sessionType == "gnome" then "${gnome.gnometerminal}/bin/gnome-terminal -ls" else
|
2008-01-16 16:33:09 +01:00
|
|
|
abort ("unknown session type ${sessionType}");
|
2007-03-01 00:00:09 +01:00
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
windowManager =
|
2007-11-09 19:49:45 +01:00
|
|
|
let wm = cfg.windowManager; in
|
2007-03-28 23:16:35 +02:00
|
|
|
if wm != "" then wm else
|
|
|
|
if sessionType == "gnome" then "metacity" else
|
|
|
|
if sessionType == "kde" then "none" /* started by startkde */ else
|
|
|
|
"twm";
|
|
|
|
|
|
|
|
|
2007-05-28 16:09:04 +02:00
|
|
|
modules =
|
2008-10-10 18:45:56 +02:00
|
|
|
|
|
|
|
getAttr ["modulesFirst"] [] videoDriverModules
|
2008-01-07 23:56:16 +01:00
|
|
|
++ [
|
2007-05-29 21:53:03 +02:00
|
|
|
xorg.xorgserver
|
|
|
|
xorg.xf86inputkeyboard
|
|
|
|
xorg.xf86inputmouse
|
|
|
|
]
|
2008-10-10 18:45:56 +02:00
|
|
|
++ getAttr ["modules"] [] videoDriverModules
|
2008-05-16 09:32:00 +02:00
|
|
|
++ (optional cfg.synaptics.enable ["${pkgs.synaptics}/${xorg.xorgserver}" /*xorg.xf86inputevdev*/]);
|
2008-01-04 11:54:33 +01:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
|
2008-08-27 12:00:49 +02:00
|
|
|
fontsForXServer =
|
|
|
|
fontDirectories ++
|
|
|
|
# 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
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
configFile = stdenv.mkDerivation {
|
2006-11-28 23:27:56 +01:00
|
|
|
name = "xserver.conf";
|
|
|
|
src = ./xserver.conf;
|
2008-08-27 12:06:25 +02:00
|
|
|
inherit fontsForXServer videoDriver resolutions;
|
2008-01-04 11:36:14 +01:00
|
|
|
isClone = if cfg.isClone then "on" else "off";
|
2007-11-06 01:00:29 +01:00
|
|
|
|
2008-05-16 09:32:00 +02:00
|
|
|
synapticsInputDevice = if cfg.synaptics.enable then ''
|
2008-01-04 11:28:12 +01:00
|
|
|
Section "InputDevice"
|
|
|
|
Identifier "Touchpad[0]"
|
|
|
|
Driver "synaptics"
|
2008-05-16 09:32:00 +02:00
|
|
|
Option "Device" "${cfg.synaptics.dev}"
|
2008-01-04 11:28:12 +01:00
|
|
|
Option "Protocol" "PS/2"
|
|
|
|
Option "LeftEdge" "1700"
|
|
|
|
Option "RightEdge" "5300"
|
|
|
|
Option "TopEdge" "1700"
|
|
|
|
Option "BottomEdge" "4200"
|
|
|
|
Option "FingerLow" "25"
|
|
|
|
Option "FingerHigh" "30"
|
|
|
|
Option "MaxTapTime" "180"
|
|
|
|
Option "MaxTapMove" "220"
|
|
|
|
Option "VertScrollDelta" "100"
|
2008-05-16 09:32:00 +02:00
|
|
|
Option "MinSpeed" "${cfg.synaptics.minSpeed}"
|
|
|
|
Option "MaxSpeed" "${cfg.synaptics.maxSpeed}"
|
2008-01-04 11:28:12 +01:00
|
|
|
Option "AccelFactor" "0.0010"
|
|
|
|
Option "SHMConfig" "on"
|
|
|
|
Option "Repeater" "/dev/input/mice"
|
|
|
|
Option "TapButton1" "1"
|
|
|
|
Option "TapButton2" "2"
|
|
|
|
Option "TapButton3" "3"
|
2009-01-02 20:41:39 +01:00
|
|
|
Option "VertTwoFingerScroll" "${if cfg.synaptics.twoFingerScroll then "1" else "0"}"
|
|
|
|
Option "HorizTwoFingerScroll" "${if cfg.synaptics.twoFingerScroll then "1" else "0"}"
|
2008-01-04 11:28:12 +01:00
|
|
|
EndSection
|
|
|
|
'' else "";
|
|
|
|
|
|
|
|
xkbOptions = if cfg.xkbOptions == "" then "" else ''
|
|
|
|
Option "XkbOptions" "${cfg.xkbOptions}"
|
|
|
|
'';
|
2007-11-06 01:00:29 +01:00
|
|
|
|
2008-03-10 18:33:13 +01:00
|
|
|
xkbModel = cfg.xkbModel;
|
2007-11-09 19:49:45 +01:00
|
|
|
layout = cfg.layout;
|
2007-11-06 01:00:29 +01:00
|
|
|
|
2008-05-16 09:32:00 +02:00
|
|
|
corePointer = if cfg.synaptics.enable then "Touchpad[0]" else "Mouse[0]";
|
2007-11-06 01:00:29 +01:00
|
|
|
|
|
|
|
internalAGPGART =
|
2008-01-04 11:28:12 +01:00
|
|
|
if cfg.useInternalAGPGART == "yes" then
|
|
|
|
'' Option "UseInternalAGPGART" "yes"''
|
|
|
|
else if cfg.useInternalAGPGART == "no" then
|
2008-07-23 16:13:27 +02:00
|
|
|
'' Option "UseInternalAGPGART" "no"''
|
2008-01-04 11:28:12 +01:00
|
|
|
else "";
|
2007-11-06 01:00:29 +01:00
|
|
|
|
2007-11-09 19:49:45 +01:00
|
|
|
extraDeviceConfig = cfg.extraDeviceConfig;
|
|
|
|
extraMonitorSettings = cfg.extraMonitorSettings;
|
2008-01-02 22:16:58 +01:00
|
|
|
extraDisplaySettings = cfg.extraDisplaySettings;
|
2007-11-09 19:49:45 +01:00
|
|
|
extraModules = cfg.extraModules;
|
|
|
|
serverLayoutOptions = cfg.serverLayoutOptions;
|
|
|
|
defaultDepth = cfg.defaultDepth;
|
2008-10-24 12:30:38 +02:00
|
|
|
virtualScreen = if cfg.virtualScreen != null then
|
|
|
|
"Virtual ${toString cfg.virtualScreen.x} ${toString cfg.virtualScreen.y}"
|
|
|
|
else "";
|
2007-09-24 11:02:43 +02:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
xfs = if cfg.useXFS == false then "" else
|
|
|
|
''FontPath "${toString cfg.useXFS}"'';
|
2007-12-25 13:16:38 +01:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
buildCommand = ''
|
2007-02-25 16:53:57 +01:00
|
|
|
buildCommand= # urgh, don't substitute this
|
2007-02-26 22:39:07 +01:00
|
|
|
|
2007-02-25 16:53:57 +01:00
|
|
|
export fontPaths=
|
2008-08-27 12:06:25 +02:00
|
|
|
for i in $fontsForXServer; do
|
2008-01-04 11:28:12 +01:00
|
|
|
if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then
|
2007-02-25 16:53:57 +01:00
|
|
|
for j in $(find $i -name fonts.dir); do
|
2008-01-04 11:28:12 +01:00
|
|
|
fontPaths="''${fontPaths}FontPath \"$(dirname $j)\"''\n"
|
2007-02-25 16:53:57 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
2007-02-26 22:39:07 +01:00
|
|
|
|
|
|
|
export modulePaths=
|
2007-02-27 00:11:32 +01:00
|
|
|
for i in $(find ${toString modules} -type d); do
|
2008-01-07 23:56:16 +01:00
|
|
|
if ls $i/*.so* > /dev/null 2>&1; then
|
2008-01-04 11:28:12 +01:00
|
|
|
modulePaths="''${modulePaths}ModulePath \"$i\"''\n"
|
2007-02-26 22:39:07 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2008-01-08 00:12:02 +01:00
|
|
|
export moduleSection=""
|
|
|
|
export screen=""
|
|
|
|
export device=""
|
|
|
|
export extensions=""
|
|
|
|
|
|
|
|
|
2007-05-28 16:09:04 +02:00
|
|
|
#if only my gf were this dirty
|
2008-01-04 11:28:12 +01:00
|
|
|
if test "${toString videoDriver}" == "nvidia"; then
|
2007-10-03 16:48:41 +02:00
|
|
|
export screen='
|
2008-01-04 11:28:12 +01:00
|
|
|
Option "AddARGBGLXVisuals" "true"
|
|
|
|
Option "DisableGLXRootClipping" "true"
|
2008-07-23 16:13:27 +02:00
|
|
|
Option "RandRRotation" "on"
|
2007-10-03 16:48:41 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
export device='
|
2008-01-04 11:28:12 +01:00
|
|
|
Option "RenderAccel" "true"
|
|
|
|
Option "AllowGLXWithComposite" "true"
|
|
|
|
Option "AddARGBGLXVisuals" "true"
|
2007-10-03 16:48:41 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
export extensions='
|
2008-01-04 11:28:12 +01:00
|
|
|
Option "Composite" "Enable"
|
2007-10-03 16:48:41 +02:00
|
|
|
'
|
2007-05-28 16:09:04 +02:00
|
|
|
fi
|
2008-07-23 16:13:27 +02:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
if [ "${toString videoDriver}" = i810 ]; then
|
|
|
|
export extensions='
|
|
|
|
Option "Composite" "Enable"
|
|
|
|
';
|
|
|
|
fi;
|
2007-05-28 16:09:04 +02:00
|
|
|
|
2008-04-11 11:20:39 +02:00
|
|
|
if [ "${toString videoDriver}" = ati ]; then
|
|
|
|
export extensions='
|
|
|
|
Option "Composite" "Enable"
|
|
|
|
';
|
|
|
|
fi;
|
|
|
|
|
2008-06-28 09:46:50 +02:00
|
|
|
if [ "${toString videoDriver}" = radeonhd ]; then
|
|
|
|
export extensions='
|
|
|
|
Option "Composite" "Enable"
|
|
|
|
';
|
|
|
|
fi;
|
|
|
|
|
2007-02-25 16:53:57 +01:00
|
|
|
substituteAll $src $out
|
2008-01-04 11:36:14 +01:00
|
|
|
''; # */
|
2006-11-28 23:27:56 +01:00
|
|
|
};
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2008-01-04 11:54:33 +01:00
|
|
|
clientScript = pkgs.writeText "xclient" ''
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
source /etc/profile
|
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
exec > $HOME/.Xerrors 2>&1
|
2007-03-30 14:33:42 +02:00
|
|
|
|
|
|
|
|
2007-04-02 17:01:09 +02:00
|
|
|
### Load X defaults.
|
2007-03-30 14:33:42 +02:00
|
|
|
if test -e ~/.Xdefaults; then
|
|
|
|
${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
|
|
|
|
fi
|
2007-04-02 17:01:09 +02:00
|
|
|
|
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
${if cfg.startSSHAgent then ''
|
2007-04-02 17:01:09 +02:00
|
|
|
### Start the SSH agent.
|
2008-01-04 11:54:33 +01:00
|
|
|
export SSH_ASKPASS=${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass
|
|
|
|
eval $(${pkgs.openssh}/bin/ssh-agent)
|
2008-01-04 11:28:12 +01:00
|
|
|
'' else ""}
|
2007-09-01 19:57:04 +02:00
|
|
|
|
|
|
|
### Allow user to override system-wide configuration
|
|
|
|
if test -f ~/.xsession; then
|
|
|
|
source ~/.xsession;
|
|
|
|
fi
|
2007-03-06 01:07:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
### Start a window manager.
|
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
${if windowManager == "twm" then ''
|
2007-03-28 23:16:35 +02:00
|
|
|
${xorg.twm}/bin/twm &
|
2008-01-04 11:28:12 +01:00
|
|
|
''
|
2007-03-01 01:00:16 +01:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
else if windowManager == "metacity" then ''
|
2008-01-04 11:54:33 +01:00
|
|
|
env LD_LIBRARY_PATH=${xorg.libX11}/lib:${xorg.libXext}/lib:/usr/lib/
|
2007-03-28 23:16:35 +02:00
|
|
|
# !!! Hack: load the schemas for Metacity.
|
2008-01-04 11:28:12 +01:00
|
|
|
GCONF_CONFIG_SOURCE=xml::~/.gconf ${gnome.GConf}/bin/gconftool-2 \
|
2009-01-02 17:07:21 +01:00
|
|
|
--makefile-install-rule ${gnome.metacity}/etc/gconf/schemas/*.schemas # */
|
2007-03-28 23:16:35 +02:00
|
|
|
${gnome.metacity}/bin/metacity &
|
2008-01-04 11:28:12 +01:00
|
|
|
''
|
2007-03-28 23:16:35 +02:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
else if windowManager == "kwm" then ''
|
2008-01-04 11:54:33 +01:00
|
|
|
${pkgs.kdebase}/bin/kwin &
|
2008-01-04 11:28:12 +01:00
|
|
|
''
|
2007-03-01 01:00:16 +01:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
else if windowManager == "compiz" then ''
|
2007-03-28 23:16:35 +02:00
|
|
|
# !!! Hack: load the schemas for Compiz.
|
2008-01-04 11:28:12 +01:00
|
|
|
GCONF_CONFIG_SOURCE=xml::~/.gconf ${gnome.GConf}/bin/gconftool-2 \
|
2009-01-02 17:07:21 +01:00
|
|
|
--makefile-install-rule ${pkgs.compiz}/etc/gconf/schemas/*.schemas # */
|
2007-03-28 23:16:35 +02:00
|
|
|
|
|
|
|
# !!! Hack: turn on most Compiz modules.
|
2008-01-04 11:28:12 +01:00
|
|
|
${gnome.GConf}/bin/gconftool-2 -t list --list-type=string \
|
|
|
|
--set /apps/compiz/general/allscreens/options/active_plugins \
|
2007-03-28 23:16:35 +02:00
|
|
|
[gconf,png,decoration,wobbly,fade,minimize,move,resize,cube,switcher,rotate,place,scale,water]
|
|
|
|
|
|
|
|
# Start Compiz and the GTK-style window decorator.
|
2008-01-04 11:54:33 +01:00
|
|
|
env LD_LIBRARY_PATH=${xorg.libX11}/lib:${xorg.libXext}/lib:/usr/lib/
|
2008-01-16 16:33:09 +01:00
|
|
|
${pkgs.compiz}/bin/compiz gconf ${cfg.renderingFlag} &
|
2008-01-04 11:54:33 +01:00
|
|
|
${pkgs.compiz}/bin/gtk-window-decorator --sync &
|
2008-01-04 11:28:12 +01:00
|
|
|
''
|
2008-01-16 17:49:22 +01:00
|
|
|
|
|
|
|
else if windowManager == "xmonad" then ''
|
|
|
|
${pkgs.xmonad}/bin/xmonad &
|
|
|
|
''
|
2008-01-04 11:28:12 +01:00
|
|
|
|
|
|
|
else if windowManager == "none" then ''
|
2007-03-28 23:16:35 +02:00
|
|
|
# The session starter will start the window manager.
|
2008-01-04 11:28:12 +01:00
|
|
|
''
|
2007-03-01 01:00:16 +01:00
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
else abort ("unknown window manager " + windowManager)}
|
2009-01-25 16:48:25 +01:00
|
|
|
WMpid=$!
|
2007-03-06 01:07:00 +01:00
|
|
|
|
|
|
|
### Show a background image.
|
2007-03-28 23:16:35 +02:00
|
|
|
# (but not if we're starting a full desktop environment that does it for us)
|
2008-01-04 11:28:12 +01:00
|
|
|
${if sessionType != "kde" then ''
|
2007-03-01 01:00:16 +01:00
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
if test -e $HOME/.background-image; then
|
2008-01-04 11:54:33 +01:00
|
|
|
${pkgs.feh}/bin/feh --bg-scale $HOME/.background-image
|
2007-03-28 23:16:35 +02:00
|
|
|
fi
|
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
'' else ""}
|
2007-03-28 23:16:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
### Start the session.
|
2008-01-04 11:28:12 +01:00
|
|
|
${if sessionType == "kde" then ''
|
2007-03-28 23:16:35 +02:00
|
|
|
|
|
|
|
# Start KDE.
|
2008-01-04 11:54:33 +01:00
|
|
|
export KDEDIRS=$HOME/.nix-profile:/nix/var/nix/profiles/default:${pkgs.kdebase}:${pkgs.kdelibs}
|
|
|
|
export XDG_CONFIG_DIRS=${pkgs.kdebase}/etc/xdg:${pkgs.kdelibs}/etc/xdg
|
|
|
|
export XDG_DATA_DIRS=${pkgs.kdebase}/share
|
|
|
|
exec ${pkgs.kdebase}/bin/startkde
|
2007-03-28 23:16:35 +02:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
'' else ''
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
# For all other session types, we currently just start a
|
|
|
|
# terminal of the kind indicated by sessionCmd.
|
|
|
|
# !!! yes, this means that you 'log out' by killing the X server.
|
|
|
|
while ${sessionCmd}; do
|
2009-01-02 17:07:21 +01:00
|
|
|
sleep 1
|
2007-03-28 23:16:35 +02:00
|
|
|
done
|
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
''}
|
2007-03-28 23:16:35 +02:00
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
'';
|
2007-02-25 17:20:14 +01:00
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-02-25 23:27:17 +01:00
|
|
|
xserverArgs = [
|
|
|
|
"-ac"
|
2007-05-28 16:09:04 +02:00
|
|
|
"-logverbose"
|
|
|
|
"-verbose"
|
2007-02-25 23:27:17 +01:00
|
|
|
"-terminate"
|
2008-01-04 11:54:33 +01:00
|
|
|
"-logfile" "/var/log/X.${toString cfg.display}.log"
|
2007-02-27 00:11:32 +01:00
|
|
|
"-config ${configFile}"
|
2008-01-04 11:54:33 +01:00
|
|
|
":${toString cfg.display}" "vt${toString cfg.tty}"
|
|
|
|
"-xkbdir" "${pkgs.xkeyboard_config}/etc/X11/xkb"
|
2008-01-04 11:28:12 +01:00
|
|
|
] ++ optional (!config.services.xserver.tcpEnable) "-nolisten tcp";
|
2007-02-25 23:27:17 +01:00
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2008-01-04 11:54:33 +01:00
|
|
|
slimConfig = pkgs.writeText "slim.cfg" ''
|
2008-01-04 11:28:12 +01:00
|
|
|
xauth_path ${xorg.xauth}/bin/xauth
|
|
|
|
default_xserver ${xorg.xorgserver}/bin/X
|
|
|
|
xserver_arguments ${toString xserverArgs}
|
|
|
|
login_cmd exec ${stdenv.bash}/bin/sh ${clientScript}
|
2008-03-10 18:27:37 +01:00
|
|
|
halt_cmd ${pkgs.upstart}/sbin/shutdown -h now
|
|
|
|
reboot_cmd ${pkgs.upstart}/sbin/shutdown -r now
|
2008-04-21 15:05:35 +02:00
|
|
|
${if cfg.slim.defaultUser != "" then "default_user " + cfg.slim.defaultUser else ""}
|
|
|
|
${if cfg.slim.hideCursor then "hidecursor true" else ""}
|
2008-01-04 11:28:12 +01:00
|
|
|
'';
|
2007-02-25 23:27:17 +01:00
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-06-05 13:51:59 +02:00
|
|
|
# Unpack the SLiM theme, or use the default.
|
|
|
|
slimThemesDir =
|
|
|
|
let
|
|
|
|
unpackedTheme = stdenv.mkDerivation {
|
|
|
|
name = "slim-theme";
|
2008-01-04 11:28:12 +01:00
|
|
|
buildCommand = ''
|
2007-06-05 13:51:59 +02:00
|
|
|
ensureDir $out
|
|
|
|
cd $out
|
2007-11-09 19:49:45 +01:00
|
|
|
unpackFile ${cfg.slim.theme}
|
2007-06-05 13:51:59 +02:00
|
|
|
ln -s * default
|
2008-01-04 11:28:12 +01:00
|
|
|
'';
|
2007-06-05 13:51:59 +02:00
|
|
|
};
|
2008-01-04 11:54:33 +01:00
|
|
|
in if cfg.slim.theme == null then "${pkgs.slim}/share/slim/themes" else unpackedTheme;
|
2007-06-05 13:51:59 +02:00
|
|
|
|
2008-05-23 08:40:16 +02:00
|
|
|
nvidiaDrivers = (config.boot.kernelPackages pkgs).nvidiaDrivers;
|
2007-06-05 13:51:59 +02:00
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
oldJob = rec {
|
|
|
|
# Warning the indentation is wrong since here in order to don't produce noise in diffs.
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
|
|
name = "xserver";
|
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
|
|
|
|
extraPath = [
|
|
|
|
xorg.xrandr
|
2007-03-30 14:33:42 +02:00
|
|
|
xorg.xrdb
|
|
|
|
xorg.setxkbmap
|
2008-10-29 17:15:58 +01:00
|
|
|
xorg.iceauth # required for KDE applications (it's called by dcopserver)
|
2008-01-04 11:54:33 +01:00
|
|
|
pkgs.feh
|
2007-03-06 01:07:00 +01:00
|
|
|
]
|
|
|
|
++ optional (windowManager == "twm") [
|
|
|
|
xorg.twm
|
|
|
|
]
|
|
|
|
++ optional (windowManager == "metacity") [
|
|
|
|
gnome.metacity
|
|
|
|
]
|
|
|
|
++ optional (windowManager == "compiz") [
|
2008-01-04 11:54:33 +01:00
|
|
|
pkgs.compiz
|
2007-03-06 01:07:00 +01:00
|
|
|
]
|
|
|
|
++ optional (sessionType == "xterm") [
|
2008-01-04 11:54:33 +01:00
|
|
|
pkgs.xterm
|
2007-03-06 01:07:00 +01:00
|
|
|
]
|
|
|
|
++ optional (sessionType == "gnome") [
|
|
|
|
gnome.gnometerminal
|
|
|
|
gnome.GConf
|
|
|
|
gnome.gconfeditor
|
2007-03-28 23:16:35 +02:00
|
|
|
]
|
|
|
|
++ optional (sessionType == "kde") [
|
2008-01-04 11:54:33 +01:00
|
|
|
pkgs.kdelibs
|
|
|
|
pkgs.kdebase
|
2007-03-28 23:16:35 +02:00
|
|
|
xorg.xset # used by startkde, non-essential
|
2008-01-07 23:56:16 +01:00
|
|
|
]
|
|
|
|
++ optional (videoDriver == "nvidia") [
|
2008-06-06 11:13:16 +02:00
|
|
|
kernelPackages.nvidiaDrivers
|
2007-03-06 01:07:00 +01:00
|
|
|
];
|
|
|
|
|
2007-03-30 14:55:09 +02:00
|
|
|
|
|
|
|
extraEtc =
|
|
|
|
optional (sessionType == "kde")
|
2008-01-04 11:54:33 +01:00
|
|
|
{ source = "${pkgs.xkeyboard_config}/etc/X11/xkb";
|
2007-03-30 14:55:09 +02:00
|
|
|
target = "X11/xkb";
|
2007-12-31 09:55:40 +01:00
|
|
|
}
|
|
|
|
++
|
2008-01-04 11:36:14 +01:00
|
|
|
optional cfg.exportConfiguration
|
2008-01-04 11:28:12 +01:00
|
|
|
{ source = "${configFile}";
|
|
|
|
target = "X11/xorg.conf";
|
|
|
|
};
|
2007-03-30 14:55:09 +02:00
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
job = ''
|
2008-01-04 11:36:14 +01:00
|
|
|
start on ${if cfg.autorun then "network-interfaces" else "never"}
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2007-02-27 01:50:22 +01:00
|
|
|
start script
|
2007-06-05 13:51:59 +02:00
|
|
|
|
2007-06-09 21:46:57 +02:00
|
|
|
rm -f /var/run/opengl-driver
|
2007-05-28 16:09:04 +02:00
|
|
|
${if videoDriver == "nvidia"
|
2008-01-07 23:56:16 +01:00
|
|
|
then ''
|
2008-06-06 11:13:16 +02:00
|
|
|
ln -sf ${kernelPackages.nvidiaDrivers} /var/run/opengl-driver
|
2008-01-07 23:56:16 +01:00
|
|
|
''
|
2008-07-23 16:13:27 +02:00
|
|
|
else if cfg.driSupport
|
2008-01-04 11:54:33 +01:00
|
|
|
then "ln -sf ${pkgs.mesa} /var/run/opengl-driver"
|
2007-03-06 01:07:00 +01:00
|
|
|
else ""
|
2007-05-28 16:09:04 +02:00
|
|
|
}
|
2007-06-05 13:51:59 +02:00
|
|
|
|
2008-01-04 11:28:12 +01:00
|
|
|
rm -f /var/log/slim.log
|
2007-06-05 13:51:59 +02:00
|
|
|
|
2007-02-27 01:50:22 +01:00
|
|
|
end script
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2007-02-27 01:50:22 +01:00
|
|
|
env SLIM_CFGFILE=${slimConfig}
|
2007-06-05 13:51:59 +02:00
|
|
|
env SLIM_THEMESDIR=${slimThemesDir}
|
2008-01-04 11:54:33 +01:00
|
|
|
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
|
|
|
|
env XKB_BINDIR=${xorg.xkbcomp}/bin # Needed for the Xkb extension.
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2008-01-07 23:56:16 +01:00
|
|
|
${if videoDriver == "nvidia"
|
2008-06-06 11:13:16 +02:00
|
|
|
then "env LD_LIBRARY_PATH=${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidiaDrivers}/lib"
|
2008-01-07 23:56:16 +01:00
|
|
|
else ""
|
|
|
|
}
|
|
|
|
|
|
|
|
${if videoDriver != "nvidia"
|
2008-01-04 11:54:33 +01:00
|
|
|
then "env XORG_DRI_DRIVER_PATH=${pkgs.mesa}/lib/modules/dri"
|
2007-03-06 01:07:00 +01:00
|
|
|
else ""
|
2008-01-07 23:56:16 +01:00
|
|
|
}
|
2007-02-25 23:27:17 +01:00
|
|
|
|
2008-01-04 11:54:33 +01:00
|
|
|
exec ${pkgs.slim}/bin/slim
|
2008-01-04 11:28:12 +01:00
|
|
|
'';
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
mkIf cfg.enable {
|
|
|
|
require = [
|
|
|
|
options
|
|
|
|
|
|
|
|
# services.extraJobs
|
|
|
|
(import ../upstart-jobs/default.nix)
|
|
|
|
|
|
|
|
# environment.etc
|
|
|
|
(import ../etc/default.nix)
|
|
|
|
|
2009-01-02 17:07:39 +01:00
|
|
|
# fonts.fonts
|
|
|
|
(import ../system/fonts.nix)
|
|
|
|
|
2009-01-02 17:07:21 +01:00
|
|
|
# boot.extraModulePackages
|
|
|
|
# security.extraSetuidPrograms
|
|
|
|
# environment.extraPackages
|
|
|
|
];
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
extraModulePackages = mkIf (cfg.videoDriver == "nvidia") [
|
|
|
|
kernelPackages.nvidiaDrivers
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
security = {
|
|
|
|
extraSetuidPrograms = mkIf (cfg.sessionType == "kde") [
|
|
|
|
"kcheckpass"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
etc = [
|
|
|
|
{ source = ../etc/pam.d/kde;
|
|
|
|
target = "pam.d/kde";
|
|
|
|
}
|
|
|
|
{ source = ../etc/pam.d/slim;
|
|
|
|
target = "pam.d/slim";
|
|
|
|
}
|
|
|
|
] ++ oldJob.extraEtc;
|
|
|
|
|
|
|
|
extraPackages =
|
|
|
|
oldJob.extraPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
extraJobs = [{
|
|
|
|
inherit (oldJob) name job;
|
|
|
|
}];
|
|
|
|
};
|
2006-11-28 23:27:56 +01:00
|
|
|
}
|