2007-02-26 22:39:07 +01:00
|
|
|
{ stdenv, writeText, lib, xorg, xterm, slim
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
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-02-26 22:39:07 +01:00
|
|
|
${xorg.twm}/bin/twm &
|
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 = "
|
2006-11-29 23:34:59 +01:00
|
|
|
#start on network-interfaces
|
2006-11-28 23:27:56 +01:00
|
|
|
|
|
|
|
start script
|
|
|
|
|
|
|
|
end script
|
|
|
|
|
2007-02-25 23:27:17 +01:00
|
|
|
env SLIM_CFGFILE=${slimConfig}
|
|
|
|
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
|
|
|
|
|
|
|
|
exec ${slim}/bin/slim
|
2006-11-28 23:27:56 +01:00
|
|
|
";
|
|
|
|
|
|
|
|
}
|