1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-24 02:46:38 +00:00
nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix

80 lines
2.2 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
xcfg = config.services.xserver;
cfg = xcfg.desktopManager;
# 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;
in
{
# 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.
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
];
options = {
services.xserver.desktopManager = {
session = mkOption {
2013-10-30 16:37:45 +00:00
internal = true;
default = [];
example = singleton
{ name = "kde";
bgSupport = true;
start = "...";
};
2013-10-30 16:37:45 +00:00
description = ''
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
'';
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 {
type = types.str;
default = "";
example = "none";
description = "Default desktop manager loaded if none have been chosen.";
apply = defaultDM:
if defaultDM == "" && cfg.session.list != [] then
(head cfg.session.list).name
else if any (w: w.name == defaultDM) cfg.session.list then
defaultDM
else
throw "Default desktop manager ($(defaultDM)) not found.";
};
};
};
config = {
services.xserver.displayManager.session = cfg.session.list;
environment.systemPackages =
mkIf cfg.session.needBGPackages [ pkgs.feh ];
};
}