2007-03-01 01:00:16 +01:00
|
|
|
{ stdenv, writeText, lib, xorg, mesa, xterm, slim, metacity, GConf, compiz
|
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];
|
|
|
|
|
|
|
|
optional = condition: x: if condition then [x] else [];
|
|
|
|
|
|
|
|
|
|
|
|
videoDriver = getCfg "videoDriver";
|
|
|
|
|
|
|
|
resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (getCfg "resolutions");
|
|
|
|
|
2007-03-01 00:00:09 +01:00
|
|
|
windowManager = getCfg "windowManager";
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
|
|
|
modules = [
|
2007-02-26 22:39:07 +01:00
|
|
|
xorg.xorgserver
|
|
|
|
xorg.xf86inputkeyboard
|
|
|
|
xorg.xf86inputmouse
|
2007-02-27 00:11:32 +01:00
|
|
|
]
|
|
|
|
++ optional (videoDriver == "vesa") xorg.xf86videovesa
|
|
|
|
++ optional (videoDriver == "i810") xorg.xf86videoi810;
|
|
|
|
|
2007-02-26 22:39:07 +01: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-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-01 00:00:09 +01:00
|
|
|
${if windowManager == "twm" then "
|
2007-02-26 22:39:07 +01:00
|
|
|
${xorg.twm}/bin/twm &
|
2007-03-01 01:00:16 +01:00
|
|
|
"
|
|
|
|
|
|
|
|
else if windowManager == "metacity" then "
|
2007-03-01 00:18:16 +01: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-03-01 00:00:09 +01:00
|
|
|
${metacity}/bin/metacity &
|
2007-03-01 01:00:16 +01: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
|
|
|
|
${GConf}/bin/gconftool-2 -t list --list-type=string --set /apps/compiz/general/allscreens/options/active_plugins [gconf,png,decoration,fade,minimize,move,resize,cube,switcher,rotate,place,scale,water,wobbly,zoom]
|
|
|
|
${compiz}/bin/compiz gconf &
|
|
|
|
/nix/store/n4wkqkl9l1bikdq39hcxg1rwywavzzh9-compiz-0.3.6/bin/gtk-window-decorator &
|
|
|
|
"
|
|
|
|
|
|
|
|
else abort ("unknown window manager "+ windowManager)}
|
|
|
|
|
2007-02-25 17:20:14 +01:00
|
|
|
${xterm}/bin/xterm -ls
|
|
|
|
";
|
|
|
|
|
2007-02-27 00:11:32 +01:00
|
|
|
|
2007-02-25 23:27:17 +01:00
|
|
|
xserverArgs = [
|
|
|
|
"-ac"
|
|
|
|
"-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}"
|
|
|
|
];
|
|
|
|
|
|
|
|
# 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
|
|
|
|
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";
|
|
|
|
|
|
|
|
job = "
|
2007-02-27 01:50:22 +01:00
|
|
|
#start on network-interfaces
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2007-02-27 01:50:22 +01: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 23:27:56 +01:00
|
|
|
|
2007-02-27 01:50:22 +01:00
|
|
|
env SLIM_CFGFILE=${slimConfig}
|
|
|
|
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
|
2006-11-28 23:27:56 +01:00
|
|
|
|
2007-02-27 01:50:22 +01:00
|
|
|
${if getCfg "driSupport"
|
|
|
|
then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri"
|
|
|
|
else ""}
|
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
|
|
|
";
|
|
|
|
|
|
|
|
}
|