2007-03-06 01:07:00 +01:00
|
|
|
{ stdenv, writeText, lib, xorg, mesa, xterm, slim, gnome
|
|
|
|
, compiz, feh
|
2007-03-28 23:16:35 +02:00
|
|
|
, kdelibs, kdebase
|
2007-03-30 14:33:42 +02:00
|
|
|
, xkeyboard_config
|
2007-04-02 17:01:09 +02:00
|
|
|
, openssh, x11_ssh_askpass
|
2007-05-28 17:39:25 +02:00
|
|
|
, nvidiaDrivers, libX11, libXext
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
, config
|
|
|
|
|
2006-11-28 23:27:56 +01:00
|
|
|
, # Virtual console for the X server.
|
|
|
|
tty ? 7
|
|
|
|
|
|
|
|
, # X display number.
|
|
|
|
display ? 0
|
|
|
|
|
2007-02-25 16:53:57 +01:00
|
|
|
, # List of font directories.
|
|
|
|
fontDirectories
|
|
|
|
|
2006-11-28 23:27:56 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
getCfg = option: config.get ["services" "xserver" option];
|
2007-06-05 13:51:59 +02:00
|
|
|
getCfg2 = option: config.get (["services" "xserver"] ++ option);
|
2007-02-27 00:11:32 +01:00
|
|
|
|
|
|
|
optional = condition: x: if condition then [x] else [];
|
|
|
|
|
2007-05-28 17:39:25 +02:00
|
|
|
#Beryl parameters
|
|
|
|
#berylcore
|
|
|
|
#berylmanager
|
|
|
|
#berylemerald
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
# Get a bunch of user settings.
|
2007-02-27 00:11:32 +01:00
|
|
|
videoDriver = getCfg "videoDriver";
|
|
|
|
resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (getCfg "resolutions");
|
2007-03-06 01:07:00 +01:00
|
|
|
sessionType = getCfg "sessionType";
|
|
|
|
sessionStarter = getCfg "sessionStarter";
|
|
|
|
|
|
|
|
|
|
|
|
sessionCmd =
|
|
|
|
if sessionType == "" then sessionStarter else
|
|
|
|
if sessionType == "xterm" then "${xterm}/bin/xterm -ls" else
|
2007-05-28 16:09:04 +02:00
|
|
|
if sessionType == "gnome" then "${gnome.gnometerminal}/bin/gnome-terminal -ls" else
|
2007-03-06 01:07:00 +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 =
|
|
|
|
let wm = getCfg "windowManager"; in
|
|
|
|
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 =
|
2007-05-29 21:53:03 +02:00
|
|
|
optional (videoDriver == "nvidia") nvidiaDrivers ++ #make sure it first loads the nvidia libs
|
|
|
|
[
|
|
|
|
xorg.xorgserver
|
|
|
|
xorg.xf86inputkeyboard
|
|
|
|
xorg.xf86inputmouse
|
|
|
|
]
|
|
|
|
++ optional (videoDriver == "vesa") xorg.xf86videovesa
|
|
|
|
++ optional (videoDriver == "i810") xorg.xf86videoi810
|
|
|
|
++ optional (videoDriver == "intel") xorg.xf86videointel;
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-05-29 21:53:03 +02:00
|
|
|
|
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;
|
2007-02-27 00:11:32 +01:00
|
|
|
inherit fontDirectories videoDriver resolutions;
|
2007-02-25 16:53:57 +01:00
|
|
|
buildCommand = "
|
|
|
|
buildCommand= # urgh, don't substitute this
|
2007-02-26 22:39:07 +01:00
|
|
|
|
2007-02-25 16:53:57 +01:00
|
|
|
export fontPaths=
|
|
|
|
for i in $fontDirectories; do
|
|
|
|
if test \"\${i:0:\${#NIX_STORE}}\" == \"$NIX_STORE\"; then
|
|
|
|
for j in $(find $i -name fonts.dir); do
|
|
|
|
fontPaths=\"\${fontPaths}FontPath \\\"$(dirname $j)\\\"\\n\"
|
|
|
|
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
|
2007-02-26 22:39:07 +01:00
|
|
|
if ls $i/*.so 2> /dev/null; then
|
|
|
|
modulePaths=\"\${modulePaths}ModulePath \\\"$i\\\"\\n\"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2007-05-28 16:09:04 +02:00
|
|
|
#if only my gf were this dirty
|
|
|
|
if test \"${toString videoDriver}\" == \"nvidia\"; then
|
|
|
|
export moduleSection=\"Load \\\"glx\\\" \\n \\
|
|
|
|
SubSection \\\"extmod\\\" \\n \\
|
|
|
|
Option \\\"omit xfree86-dga\\\" \\n \\
|
|
|
|
EndSubSection \\n \"
|
|
|
|
|
|
|
|
export screen=\"Option \\\"AddARGBGLXVisuals\\\" \\\"true\\\" \\n \\
|
|
|
|
Option \\\"DisableGLXRootClipping\\\" \\\"true\\\" \\n \"
|
|
|
|
export device=\"Option \\\"RenderAccel\\\" \\\"true\\\" \\n \\
|
|
|
|
Option \\\"AllowGLXWithComposite\\\" \\\"true\\\" \\n \\
|
|
|
|
Option \\\"AddARGBGLXVisuals\\\" \\\"true\\\" \\n \"
|
|
|
|
export extensions=\"Option \\\"Composite\\\" \\\"Enable\\\" \\n \"
|
|
|
|
|
2007-05-29 21:53:03 +02:00
|
|
|
else
|
|
|
|
export moduleSection='Load \"glx\" \\n \\
|
|
|
|
Load \"dri\" '
|
|
|
|
export screen=
|
|
|
|
export device=
|
|
|
|
export extensions=
|
2007-05-28 16:09:04 +02:00
|
|
|
fi
|
|
|
|
|
2007-02-25 16:53:57 +01:00
|
|
|
substituteAll $src $out
|
|
|
|
";
|
2006-11-28 23:27:56 +01:00
|
|
|
};
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-02-25 17:20:14 +01:00
|
|
|
clientScript = 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
|
|
|
|
|
|
|
|
|
|
|
${if getCfg "startSSHAgent" then "
|
|
|
|
### Start the SSH agent.
|
|
|
|
export SSH_ASKPASS=${x11_ssh_askpass}/libexec/x11-ssh-askpass
|
|
|
|
eval $(${openssh}/bin/ssh-agent)
|
|
|
|
" else ""}
|
2007-03-06 01:07:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
### Start a window manager.
|
|
|
|
|
2007-03-01 00:00:09 +01:00
|
|
|
${if windowManager == "twm" then "
|
2007-03-28 23:16:35 +02:00
|
|
|
${xorg.twm}/bin/twm &
|
2007-03-01 01:00:16 +01:00
|
|
|
"
|
|
|
|
|
|
|
|
else if windowManager == "metacity" then "
|
2007-05-28 16:09:04 +02:00
|
|
|
env LD_LIBRARY_PATH=${libX11}/lib:${libXext}/lib:/usr/lib/
|
2007-03-28 23:16:35 +02:00
|
|
|
# !!! Hack: load the schemas for Metacity.
|
|
|
|
GCONF_CONFIG_SOURCE=xml::~/.gconf ${gnome.GConf}/bin/gconftool-2 \\
|
|
|
|
--makefile-install-rule ${gnome.metacity}/etc/gconf/schemas/*.schemas
|
|
|
|
${gnome.metacity}/bin/metacity &
|
|
|
|
"
|
|
|
|
|
|
|
|
else if windowManager == "kwm" then "
|
|
|
|
${kdebase}/bin/kwin &
|
2007-03-01 01:00:16 +01:00
|
|
|
"
|
|
|
|
|
|
|
|
else if windowManager == "compiz" then "
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
# !!! Hack: load the schemas for Compiz.
|
|
|
|
GCONF_CONFIG_SOURCE=xml::~/.gconf ${gnome.GConf}/bin/gconftool-2 \\
|
|
|
|
--makefile-install-rule ${compiz}/etc/gconf/schemas/*.schemas
|
|
|
|
|
|
|
|
# !!! Hack: turn on most Compiz modules.
|
|
|
|
${gnome.GConf}/bin/gconftool-2 -t list --list-type=string \\
|
|
|
|
--set /apps/compiz/general/allscreens/options/active_plugins \\
|
|
|
|
[gconf,png,decoration,wobbly,fade,minimize,move,resize,cube,switcher,rotate,place,scale,water]
|
|
|
|
|
|
|
|
# Start Compiz and the GTK-style window decorator.
|
2007-05-28 16:09:04 +02:00
|
|
|
env LD_LIBRARY_PATH=${libX11}/lib:${libXext}/lib:/usr/lib/
|
2007-03-28 23:16:35 +02:00
|
|
|
${compiz}/bin/compiz gconf &
|
2007-05-28 16:09:04 +02:00
|
|
|
${compiz}/bin/gtk-window-decorator --sync &
|
2007-03-28 23:16:35 +02:00
|
|
|
"
|
2007-05-28 16:09:04 +02:00
|
|
|
#else if windowManager == "beryl" then "
|
|
|
|
# ${berylmanager}/bin/beryl-manager &
|
|
|
|
#"
|
2007-03-28 23:16:35 +02:00
|
|
|
|
|
|
|
else if windowManager == "none" then "
|
|
|
|
|
|
|
|
# The session starter will start the window manager.
|
|
|
|
|
2007-03-01 01:00:16 +01:00
|
|
|
"
|
|
|
|
|
2007-03-28 23:16:35 +02:00
|
|
|
else abort ("unknown window manager " + windowManager)}
|
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)
|
|
|
|
${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
|
|
|
|
${feh}/bin/feh --bg-scale $HOME/.background-image
|
|
|
|
fi
|
|
|
|
|
|
|
|
" else ""}
|
|
|
|
|
|
|
|
|
|
|
|
### Start the session.
|
|
|
|
${if sessionType == "kde" then "
|
|
|
|
|
|
|
|
# Start KDE.
|
|
|
|
export KDEDIRS=${kdebase}:${kdelibs}
|
|
|
|
export XDG_CONFIG_DIRS=${kdebase}/etc/xdg:${kdelibs}/etc/xdg
|
|
|
|
export XDG_DATA_DIRS=${kdebase}/share
|
|
|
|
exec ${kdebase}/bin/startkde
|
|
|
|
|
|
|
|
" 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
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
"}
|
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
"; # */ <- hack to fix syntax highlighting
|
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
|
|
|
"-nolisten tcp"
|
|
|
|
"-terminate"
|
|
|
|
"-logfile" "/var/log/X.${toString display}.log"
|
2007-02-27 00:11:32 +01:00
|
|
|
"-config ${configFile}"
|
2007-02-25 23:27:17 +01:00
|
|
|
":${toString display}" "vt${toString tty}"
|
2007-03-30 14:33:42 +02:00
|
|
|
"-xkbdir" "${xkeyboard_config}/etc/X11/xkb"
|
2007-02-25 23:27:17 +01:00
|
|
|
];
|
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2007-02-25 23:27:17 +01:00
|
|
|
# Note: lines must not be indented.
|
|
|
|
slimConfig = writeText "slim.cfg" "
|
2007-02-26 22:39:07 +01:00
|
|
|
xauth_path ${xorg.xauth}/bin/xauth
|
|
|
|
default_xserver ${xorg.xorgserver}/bin/X
|
2007-02-25 23:27:17 +01:00
|
|
|
xserver_arguments ${toString xserverArgs}
|
|
|
|
login_cmd exec ${stdenv.bash}/bin/sh ${clientScript}
|
|
|
|
";
|
|
|
|
|
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
|
|
|
|
theme = getCfg2 ["slim" "theme"];
|
|
|
|
unpackedTheme = stdenv.mkDerivation {
|
|
|
|
name = "slim-theme";
|
|
|
|
buildCommand = "
|
|
|
|
ensureDir $out
|
|
|
|
cd $out
|
|
|
|
unpackFile ${theme}
|
|
|
|
ln -s * default
|
|
|
|
";
|
|
|
|
};
|
|
|
|
in if theme == null then "${slim}/share/slim/themes" else unpackedTheme;
|
|
|
|
|
|
|
|
|
2006-11-28 23:27:56 +01:00
|
|
|
in
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2006-11-28 23:27:56 +01:00
|
|
|
rec {
|
|
|
|
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
|
2007-03-06 01:07:00 +01:00
|
|
|
feh
|
|
|
|
]
|
|
|
|
++ optional (windowManager == "twm") [
|
|
|
|
xorg.twm
|
|
|
|
]
|
|
|
|
++ optional (windowManager == "metacity") [
|
|
|
|
gnome.metacity
|
|
|
|
]
|
|
|
|
++ optional (windowManager == "compiz") [
|
|
|
|
compiz
|
|
|
|
]
|
2007-05-28 16:09:04 +02:00
|
|
|
#++ optional (windowManager == "beryl") [
|
|
|
|
# berylcore berylmanager berylemerald
|
|
|
|
#]
|
2007-03-06 01:07:00 +01:00
|
|
|
++ optional (sessionType == "xterm") [
|
|
|
|
xterm
|
|
|
|
]
|
|
|
|
++ optional (sessionType == "gnome") [
|
|
|
|
gnome.gnometerminal
|
|
|
|
gnome.GConf
|
|
|
|
gnome.gconfeditor
|
2007-03-28 23:16:35 +02:00
|
|
|
]
|
|
|
|
++ optional (sessionType == "kde") [
|
|
|
|
kdelibs
|
|
|
|
kdebase
|
|
|
|
xorg.iceauth # absolutely required by dcopserver
|
|
|
|
xorg.xset # used by startkde, non-essential
|
2007-03-06 01:07:00 +01:00
|
|
|
];
|
|
|
|
|
2007-03-30 14:55:09 +02:00
|
|
|
|
|
|
|
extraEtc =
|
|
|
|
optional (sessionType == "kde")
|
|
|
|
{ source = "${xkeyboard_config}/etc/X11/xkb";
|
|
|
|
target = "X11/xkb";
|
|
|
|
};
|
|
|
|
|
2007-03-06 01:07:00 +01:00
|
|
|
|
2006-11-28 23:27:56 +01:00
|
|
|
job = "
|
2007-05-01 17:27:50 +02:00
|
|
|
start on network-interfaces
|
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"
|
2007-06-09 21:46:57 +02:00
|
|
|
then "ln -sf ${nvidiaDrivers} /var/run/opengl-driver"
|
2007-05-28 16:09:04 +02:00
|
|
|
else if getCfg "driSupport"
|
2007-06-09 21:46:57 +02:00
|
|
|
then "ln -sf ${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
|
|
|
|
|
|
|
rm -f /var/log/slim.log
|
|
|
|
|
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}
|
2007-05-28 16:09:04 +02:00
|
|
|
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
|
|
|
|
env XKB_BINDIR=${xorg.xkbcomp}/bin # Needed for the Xkb extension.
|
|
|
|
env LD_LIBRARY_PATH=${libX11}/lib:${libXext}/lib:/usr/lib/ # related to xorg-sys-opengl - needed to load libglx for (AI)GLX support (for compiz)
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2007-05-28 16:09:04 +02:00
|
|
|
${if videoDriver == "nvidia"
|
|
|
|
then "env XORG_DRI_DRIVER_PATH=${nvidiaDrivers}/X11R6/lib/modules/drivers/"
|
|
|
|
else if getCfg "driSupport"
|
2007-03-06 01:07:00 +01:00
|
|
|
then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri"
|
|
|
|
else ""
|
2007-05-28 16:09:04 +02:00
|
|
|
}
|
2007-02-25 23:27:17 +01:00
|
|
|
|
2007-02-27 01:50:22 +01:00
|
|
|
exec ${slim}/bin/slim
|
2006-11-28 23:27:56 +01:00
|
|
|
";
|
|
|
|
|
|
|
|
}
|