* X session script:

- Set the desktop background to the image ~/.background-image.
  - Depending on services.xserver.sessionType, start an xterm or a
    gnome-terminal as the "desktop" :-)

* Upstart jobs can now declare extra packages to be added to the
  system path through the `extraPath' attribute.  For instance, the
  ALSA job adds alsa-utils, and the X server job adds lots of stuff
  depending on the X configuration (e.g., xrandr, gnome-terminal,
  twm).

* Create a cdrom/dvd symlink for SCSI sr? devices.

svn path=/nixos/trunk/; revision=8221
This commit is contained in:
Eelco Dolstra 2007-03-06 00:07:00 +00:00
parent ba845b19fb
commit 8d731dacad
8 changed files with 125 additions and 19 deletions

@ -505,6 +505,30 @@
}
{
name = ["services" "xserver" "sessionType"];
default = "gnome";
example = "xterm";
description = "
The kind of session to start after login. Current possibilies
are <literal>gnome</literal> (which starts
<command>gnome-terminal</command>) and <literal>xterm</literal>
(which starts <command>xterm</command>).
";
}
{
name = ["services" "xserver" "sessionStarter"];
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 not empty.
";
}
{
name = ["services" "httpd" "enable"];
default = false;

@ -208,7 +208,7 @@ rec {
nixosCheckout
setuidWrapper
]
++ (if config.get ["sound" "enable"] then [pkgs.alsaUtils] else []);
++ pkgs.lib.concatLists (map (job: job.extraPath) upstartJobs.jobs);
# We don't want to put all of `startPath' and `path' in $PATH, since

@ -125,8 +125,8 @@ import ../upstart-jobs/gather.nix {
++ optional ["services" "xserver" "enable"]
(import ../upstart-jobs/xserver.nix {
inherit config;
inherit (pkgs) stdenv writeText lib xterm slim xorg mesa compiz;
inherit (pkgs.gnome) metacity GConf;
inherit (pkgs) stdenv writeText lib xterm slim xorg mesa
gnome compiz feh;
fontDirectories = import ./fonts.nix {inherit pkgs;};
})
@ -201,6 +201,8 @@ import ../upstart-jobs/gather.nix {
++ (map makeJob (config.get ["services" "extraJobs"]))
# For the built-in logd job.
++ [pkgs.upstart];
++ [
(pkgs.upstart // {extraPath = [];})
];
}

@ -8,6 +8,8 @@ in
{
name = "alsa";
extraPath = [alsaUtils];
job = "
start on hardware-scan

@ -1,4 +1,14 @@
{runCommand}: job:
runCommand job.name {inherit (job) job;}
"ensureDir $out/etc/event.d; echo \"$job\" > $out/etc/event.d/$name"
(
runCommand job.name {inherit (job) job;}
"ensureDir $out/etc/event.d; echo \"$job\" > $out/etc/event.d/$name"
)
//
# Allow jobs to declare extra packages that should be added to the
# system path.
{
extraPath = if job ? extraPath then job.extraPath else [];
}

@ -28,6 +28,7 @@ KERNEL=="uinput", NAME="input/%k", MODE="0600"
# Create a symlink for the CD-ROM device.
KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom", SYMLINK+="cdrom cdrom-%k"
KERNEL=="sr[0-9]", BUS=="scsi", SYMLINK+="cdrom cdrom-%k"
# ALSA sound devices.

@ -78,3 +78,8 @@ EndSection
Section "Extensions"
Option "Composite" "Enable"
EndSection
Section "DRI"
Mode 0666 # !!! FIX THIS!
EndSection

@ -1,4 +1,5 @@
{ stdenv, writeText, lib, xorg, mesa, xterm, slim, metacity, GConf, compiz
{ stdenv, writeText, lib, xorg, mesa, xterm, slim, gnome
, compiz, feh
, config
@ -20,11 +21,19 @@ let
optional = condition: x: if condition then [x] else [];
# Get a bunch of user settings.
videoDriver = getCfg "videoDriver";
resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (getCfg "resolutions");
windowManager = getCfg "windowManager";
sessionType = getCfg "sessionType";
sessionStarter = getCfg "sessionStarter";
sessionCmd =
if sessionType == "" then sessionStarter else
if sessionType == "xterm" then "${xterm}/bin/xterm -ls" else
if sessionType == "gnome" then "${gnome.gnometerminal}/bin/gnome-terminal" else
abort ("unknown session type "+ sessionType);
modules = [
@ -65,28 +74,54 @@ let
clientScript = writeText "xclient" "
exec > $HOME/.Xerrors 2>&1
### Start a window manager.
${if windowManager == "twm" then "
${xorg.twm}/bin/twm &
"
else if windowManager == "metacity" then "
# !!! Hack: load the schemas for Metacity.
GCONF_CONFIG_SOURCE=xml::~/.gconf ${GConf}/bin/gconftool-2 --makefile-install-rule ${metacity}/etc/gconf/schemas/*.schemas
${metacity}/bin/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 == "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,wobbly,fade,minimize,move,resize,cube,switcher,rotate,place,scale,water,zoom]
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,zoom]
# Start Compiz and the GTK-style window decorator.
${compiz}/bin/compiz gconf &
${compiz}/bin/gtk-window-decorator &
"
else abort ("unknown window manager "+ windowManager)}
### Show a background image.
if test -e $HOME/.background-image; then
${feh}/bin/feh --bg-scale $HOME/.background-image
fi
${xterm}/bin/xterm -ls
";
### Start a 'session' (right now, this is just a terminal).
# !!! yes, this means that you 'log out' by killing the X server.
while ${sessionCmd}; do
sleep 1
done
"; # */ <- hack to fix syntax highlighting
xserverArgs = [
@ -98,6 +133,7 @@ let
":${toString display}" "vt${toString tty}"
];
# Note: lines must not be indented.
slimConfig = writeText "slim.cfg" "
xauth_path ${xorg.xauth}/bin/xauth
@ -113,22 +149,48 @@ in
rec {
name = "xserver";
extraPath = [
xorg.xrandr
feh
]
++ optional (windowManager == "twm") [
xorg.twm
]
++ optional (windowManager == "metacity") [
gnome.metacity
]
++ optional (windowManager == "compiz") [
compiz
]
++ optional (sessionType == "xterm") [
xterm
]
++ optional (sessionType == "gnome") [
gnome.gnometerminal
gnome.GConf
gnome.gconfeditor
];
job = "
#start on network-interfaces
start script
rm -f /var/state/opengl-driver
${if getCfg "driSupport"
then "ln -sf ${mesa} /var/state/opengl-driver"
else ""}
then "ln -sf ${mesa} /var/state/opengl-driver"
else ""
}
end script
env SLIM_CFGFILE=${slimConfig}
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
${if getCfg "driSupport"
then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri"
else ""}
then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri"
else ""
}
exec ${slim}/bin/slim
";