2009-01-25 16:49:08 +01:00
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
let
|
2009-01-25 16:49:18 +01:00
|
|
|
inherit (pkgs.lib) mkOption mergeOneOption mkIf filter optionalString any;
|
2009-06-26 00:08:03 +02:00
|
|
|
xcfg = config.services.xserver;
|
|
|
|
cfg = xcfg.desktopManager;
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2009-06-22 22:34:51 +02:00
|
|
|
# Whether desktop manager `d' is capable of setting a background.
|
|
|
|
# If it isn't, the `feh' program is used as a fallback.
|
2009-01-25 16:49:08 +01:00
|
|
|
needBGCond = d: ! (d ? bgSupport && d.bgSupport);
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
require = [
|
2009-05-20 01:14:45 +02:00
|
|
|
./kde.nix
|
|
|
|
./kde4.nix
|
|
|
|
./gnome.nix
|
|
|
|
./xterm.nix
|
|
|
|
./none.nix
|
2009-01-25 16:49:08 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
services = {
|
|
|
|
xserver = {
|
|
|
|
displayManager = {
|
|
|
|
session = cfg.session.list;
|
|
|
|
};
|
|
|
|
|
|
|
|
desktopManager = {
|
|
|
|
session = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [{
|
|
|
|
name = "kde";
|
|
|
|
bgSupport = true;
|
|
|
|
start = "...";
|
|
|
|
}];
|
|
|
|
description = "
|
|
|
|
Internal option used to add some common line to desktop manager
|
|
|
|
scripts before forwarding the value to the
|
|
|
|
<varname>displayManager</varname>.
|
|
|
|
";
|
|
|
|
apply = list: {
|
|
|
|
list = map (d: d // {
|
|
|
|
manage = "desktop";
|
|
|
|
start = d.start
|
|
|
|
+ optionalString (needBGCond d) ''
|
|
|
|
if test -e $HOME/.background-image; then
|
|
|
|
${pkgs.feh}/bin/feh --bg-scale $HOME/.background-image
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
}) list;
|
|
|
|
needBGPackages = [] != filter needBGCond list;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
default = mkOption {
|
|
|
|
default = "xterm";
|
|
|
|
example = "none";
|
|
|
|
description = "
|
|
|
|
Default desktop manager loaded if none have been chosen.
|
|
|
|
";
|
2009-04-12 00:28:33 +02:00
|
|
|
merge = mergeOneOption;
|
|
|
|
apply = defaultDM:
|
2009-01-25 16:49:18 +01:00
|
|
|
if any (w: w.name == defaultDM) cfg.session.list then
|
2009-01-25 16:49:08 +01:00
|
|
|
defaultDM
|
|
|
|
else
|
2009-04-12 00:28:33 +02:00
|
|
|
throw "Default desktop manager ($(defaultDM)) not found.";
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-06-26 00:08:03 +02:00
|
|
|
environment = mkIf cfg.session.needBGPackages {
|
|
|
|
x11Packages = [ pkgs.feh ];
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
|
|
|
}
|