2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2010-08-08 15:05:32 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2009-01-25 15:49:08 +00:00
|
|
|
|
|
|
|
let
|
2010-08-08 15:05:32 +01:00
|
|
|
|
2009-06-25 23:08:03 +01:00
|
|
|
xcfg = config.services.xserver;
|
|
|
|
cfg = xcfg.desktopManager;
|
2009-01-25 15:49:08 +00:00
|
|
|
|
2014-03-04 08:10:23 +00:00
|
|
|
# If desktop manager `d' isn't capable of setting a background and
|
|
|
|
# the xserver is enabled, the `feh' program is used as a fallback.
|
|
|
|
needBGCond = d: ! (d ? bgSupport && d.bgSupport) && xcfg.enable;
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2010-08-08 15:05:32 +01: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.
|
2014-07-21 11:05:57 +01:00
|
|
|
imports = [
|
2015-01-19 17:39:23 +00:00
|
|
|
./none.nix ./xterm.nix ./xfce.nix ./kde4.nix ./plasma5.nix
|
2015-01-19 21:14:36 +00:00
|
|
|
./e19.nix ./gnome3.nix ./xbmc.nix ./kodi.nix
|
2014-07-21 11:05:57 +01:00
|
|
|
];
|
2009-01-25 15:49:08 +00:00
|
|
|
|
2009-09-15 09:33:45 +01:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-15 09:33:45 +01:00
|
|
|
services.xserver.desktopManager = {
|
2009-01-25 15:49:08 +00:00
|
|
|
|
2009-09-15 09:33:45 +01:00
|
|
|
session = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
internal = true;
|
2009-09-15 09:33:45 +01:00
|
|
|
default = [];
|
2010-08-08 15:05:32 +01:00
|
|
|
example = singleton
|
|
|
|
{ name = "kde";
|
|
|
|
bgSupport = true;
|
|
|
|
start = "...";
|
|
|
|
};
|
2013-10-30 16:37:45 +00:00
|
|
|
description = ''
|
2009-09-15 09:33:45 +01:00
|
|
|
Internal option used to add some common line to desktop manager
|
|
|
|
scripts before forwarding the value to the
|
|
|
|
<varname>displayManager</varname>.
|
2013-10-30 16:37:45 +00:00
|
|
|
'';
|
2009-09-15 09:33:45 +01:00
|
|
|
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 15:49:08 +00:00
|
|
|
};
|
2009-09-15 09:33:45 +01:00
|
|
|
};
|
2009-01-25 15:49:08 +00:00
|
|
|
|
2009-09-15 09:33:45 +01:00
|
|
|
default = mkOption {
|
2013-10-30 10:02:04 +00:00
|
|
|
type = types.str;
|
2010-08-08 15:05:32 +01:00
|
|
|
default = "";
|
2009-09-15 09:33:45 +01:00
|
|
|
example = "none";
|
2010-08-08 15:05:32 +01:00
|
|
|
description = "Default desktop manager loaded if none have been chosen.";
|
2009-09-15 09:33:45 +01:00
|
|
|
apply = defaultDM:
|
2010-08-08 15:05:32 +01: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 09:33:45 +01:00
|
|
|
defaultDM
|
|
|
|
else
|
|
|
|
throw "Default desktop manager ($(defaultDM)) not found.";
|
2009-01-25 15:49:08 +00:00
|
|
|
};
|
2009-09-15 09:33:45 +01:00
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-01-25 15:49:08 +00:00
|
|
|
};
|
|
|
|
|
2009-09-15 09:33:45 +01:00
|
|
|
config = {
|
|
|
|
services.xserver.displayManager.session = cfg.session.list;
|
2013-10-30 16:52:35 +00:00
|
|
|
environment.systemPackages =
|
2009-09-15 09:33:45 +01:00
|
|
|
mkIf cfg.session.needBGPackages [ pkgs.feh ];
|
2009-01-25 15:49:08 +00:00
|
|
|
};
|
|
|
|
}
|