2007-03-01 00:00:16 +00:00
|
|
|
{ stdenv, writeText, lib, xorg, mesa, xterm, slim, metacity, GConf, compiz
|
2006-11-28 22:27:56 +00:00
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
, config
|
|
|
|
|
2006-11-28 22:27:56 +00:00
|
|
|
, # Virtual console for the X server.
|
|
|
|
tty ? 7
|
|
|
|
|
|
|
|
, # X display number.
|
|
|
|
display ? 0
|
|
|
|
|
2007-02-25 15:53:57 +00:00
|
|
|
, # List of font directories.
|
|
|
|
fontDirectories
|
|
|
|
|
2006-11-28 22:27:56 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
getCfg = option: config.get ["services" "xserver" option];
|
|
|
|
|
|
|
|
optional = condition: x: if condition then [x] else [];
|
|
|
|
|
|
|
|
|
|
|
|
videoDriver = getCfg "videoDriver";
|
|
|
|
|
|
|
|
resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (getCfg "resolutions");
|
|
|
|
|
2007-02-28 23:00:09 +00:00
|
|
|
windowManager = getCfg "windowManager";
|
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
|
|
|
|
modules = [
|
2007-02-26 21:39:07 +00:00
|
|
|
xorg.xorgserver
|
|
|
|
xorg.xf86inputkeyboard
|
|
|
|
xorg.xf86inputmouse
|
2007-02-26 23:11:32 +00:00
|
|
|
]
|
|
|
|
++ optional (videoDriver == "vesa") xorg.xf86videovesa
|
|
|
|
++ optional (videoDriver == "i810") xorg.xf86videoi810;
|
|
|
|
|
2007-02-26 21:39:07 +00:00
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
configFile = stdenv.mkDerivation {
|
2006-11-28 22:27:56 +00:00
|
|
|
name = "xserver.conf";
|
|
|
|
src = ./xserver.conf;
|
2007-02-26 23:11:32 +00:00
|
|
|
inherit fontDirectories videoDriver resolutions;
|
2007-02-25 15:53:57 +00:00
|
|
|
buildCommand = "
|
|
|
|
buildCommand= # urgh, don't substitute this
|
2007-02-26 21:39:07 +00:00
|
|
|
|
2007-02-25 15:53:57 +00: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 21:39:07 +00:00
|
|
|
|
|
|
|
export modulePaths=
|
2007-02-26 23:11:32 +00:00
|
|
|
for i in $(find ${toString modules} -type d); do
|
2007-02-26 21:39:07 +00:00
|
|
|
if ls $i/*.so 2> /dev/null; then
|
|
|
|
modulePaths=\"\${modulePaths}ModulePath \\\"$i\\\"\\n\"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2007-02-25 15:53:57 +00:00
|
|
|
substituteAll $src $out
|
|
|
|
";
|
2006-11-28 22:27:56 +00:00
|
|
|
};
|
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
|
2007-02-25 16:20:14 +00:00
|
|
|
clientScript = writeText "xclient" "
|
2007-02-28 23:00:09 +00:00
|
|
|
${if windowManager == "twm" then "
|
2007-02-26 21:39:07 +00:00
|
|
|
${xorg.twm}/bin/twm &
|
2007-03-01 00:00:16 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
else if windowManager == "metacity" then "
|
2007-02-28 23:18:16 +00:00
|
|
|
# !!! Hack: load the schemas for Metacity.
|
|
|
|
GCONF_CONFIG_SOURCE=xml::~/.gconf ${GConf}/bin/gconftool-2 --makefile-install-rule ${metacity}/etc/gconf/schemas/*.schemas
|
2007-02-28 23:00:09 +00:00
|
|
|
${metacity}/bin/metacity &
|
2007-03-01 00:00:16 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
else if windowManager == "compiz" then "
|
|
|
|
# !!! Hack: load the schemas for Compiz.
|
|
|
|
GCONF_CONFIG_SOURCE=xml::~/.gconf ${GConf}/bin/gconftool-2 --makefile-install-rule ${compiz}/etc/gconf/schemas/*.schemas
|
2007-03-04 13:15:30 +00:00
|
|
|
${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,zoom]
|
2007-03-01 00:00:16 +00:00
|
|
|
${compiz}/bin/compiz gconf &
|
2007-03-04 21:25:32 +00:00
|
|
|
${compiz}/bin/gtk-window-decorator &
|
2007-03-01 00:00:16 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
else abort ("unknown window manager "+ windowManager)}
|
|
|
|
|
2007-02-25 16:20:14 +00:00
|
|
|
${xterm}/bin/xterm -ls
|
|
|
|
";
|
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
|
2007-02-25 22:27:17 +00:00
|
|
|
xserverArgs = [
|
|
|
|
"-ac"
|
|
|
|
"-nolisten tcp"
|
|
|
|
"-terminate"
|
|
|
|
"-logfile" "/var/log/X.${toString display}.log"
|
2007-02-26 23:11:32 +00:00
|
|
|
"-config ${configFile}"
|
2007-02-25 22:27:17 +00:00
|
|
|
":${toString display}" "vt${toString tty}"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Note: lines must not be indented.
|
|
|
|
slimConfig = writeText "slim.cfg" "
|
2007-02-26 21:39:07 +00:00
|
|
|
xauth_path ${xorg.xauth}/bin/xauth
|
|
|
|
default_xserver ${xorg.xorgserver}/bin/X
|
2007-02-25 22:27:17 +00:00
|
|
|
xserver_arguments ${toString xserverArgs}
|
|
|
|
login_cmd exec ${stdenv.bash}/bin/sh ${clientScript}
|
|
|
|
";
|
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
|
2006-11-28 22:27:56 +00:00
|
|
|
in
|
|
|
|
|
2007-02-26 23:11:32 +00:00
|
|
|
|
2006-11-28 22:27:56 +00:00
|
|
|
rec {
|
|
|
|
name = "xserver";
|
|
|
|
|
|
|
|
job = "
|
2007-02-27 00:50:22 +00:00
|
|
|
#start on network-interfaces
|
2006-11-28 22:27:56 +00:00
|
|
|
|
2007-02-27 00:50:22 +00:00
|
|
|
start script
|
|
|
|
rm -f /var/state/opengl-driver
|
|
|
|
${if getCfg "driSupport"
|
|
|
|
then "ln -sf ${mesa} /var/state/opengl-driver"
|
|
|
|
else ""}
|
|
|
|
end script
|
2006-11-28 22:27:56 +00:00
|
|
|
|
2007-02-27 00:50:22 +00:00
|
|
|
env SLIM_CFGFILE=${slimConfig}
|
|
|
|
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
|
2006-11-28 22:27:56 +00:00
|
|
|
|
2007-02-27 00:50:22 +00:00
|
|
|
${if getCfg "driSupport"
|
|
|
|
then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri"
|
|
|
|
else ""}
|
2007-02-25 22:27:17 +00:00
|
|
|
|
2007-02-27 00:50:22 +00:00
|
|
|
exec ${slim}/bin/slim
|
2006-11-28 22:27:56 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
}
|