2010-08-08 16:05:32 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-01-25 16:49:08 +01:00
|
|
|
|
|
|
|
let
|
2010-08-08 16:05:32 +02:00
|
|
|
|
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);
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-01-25 16:49:08 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2010-08-08 16:05:32 +02:00
|
|
|
# Note: the order in which desktop manager modules are imported here
|
|
|
|
# determines the default: later modules (if enabled) are preferred.
|
|
|
|
# E.g., if KDE is enabled, it supersedes xterm.
|
2010-08-09 00:45:54 +02:00
|
|
|
imports = [ ./none.nix ./xterm.nix ./xfce.nix ./gnome.nix ./kde4.nix ];
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
services.xserver.desktopManager = {
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
session = mkOption {
|
|
|
|
default = [];
|
2010-08-08 16:05:32 +02:00
|
|
|
example = singleton
|
|
|
|
{ name = "kde";
|
|
|
|
bgSupport = true;
|
|
|
|
start = "...";
|
|
|
|
};
|
2009-09-15 10:33:45 +02:00
|
|
|
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;
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
2009-09-15 10:33:45 +02:00
|
|
|
};
|
2009-01-25 16:49:08 +01:00
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
default = mkOption {
|
2010-08-08 16:05:32 +02:00
|
|
|
default = "";
|
2009-09-15 10:33:45 +02:00
|
|
|
example = "none";
|
2010-08-08 16:05:32 +02:00
|
|
|
description = "Default desktop manager loaded if none have been chosen.";
|
2009-09-15 10:33:45 +02:00
|
|
|
merge = mergeOneOption;
|
|
|
|
apply = defaultDM:
|
2010-08-08 16:05:32 +02:00
|
|
|
if defaultDM == "" && cfg.session.list != [] then
|
|
|
|
(head cfg.session.list).name
|
|
|
|
else if any (w: w.name == defaultDM) cfg.session.list then
|
2009-09-15 10:33:45 +02:00
|
|
|
defaultDM
|
|
|
|
else
|
|
|
|
throw "Default desktop manager ($(defaultDM)) not found.";
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
2009-09-15 10:33:45 +02:00
|
|
|
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
|
|
|
|
2009-09-15 10:33:45 +02:00
|
|
|
config = {
|
|
|
|
services.xserver.displayManager.session = cfg.session.list;
|
|
|
|
environment.x11Packages =
|
|
|
|
mkIf cfg.session.needBGPackages [ pkgs.feh ];
|
2009-01-25 16:49:08 +01:00
|
|
|
};
|
|
|
|
}
|