Use the mergeOneOption function instead of duplicated code.

svn path=/nixos/branches/fix-style/; revision=13859
This commit is contained in:
Nicolas Pierron 2009-01-25 15:49:18 +00:00
parent 639be32a8a
commit dcc981840e
3 changed files with 8 additions and 19 deletions

View File

@ -1,8 +1,7 @@
{pkgs, config, ...}:
let
inherit (builtins) head tail;
inherit (pkgs.lib) mkOption mkIf filter optionalString any;
inherit (pkgs.lib) mkOption mergeOneOption mkIf filter optionalString any;
cfg = config.services.xserver.desktopManager;
needBGCond = d: ! (d ? bgSupport && d.bgSupport);
@ -58,10 +57,8 @@ in
Default desktop manager loaded if none have been chosen.
";
merge = name: list:
let defaultDM = head list; in
if tail list != [] then
throw "Only one default desktop manager is allowed."
else if any (w: w.name == defaultDM) cfg.session.list then
let defaultDM = mergeOneOption name list; in
if any (w: w.name == defaultDM) cfg.session.list then
defaultDM
else
throw "Default desktop manager not found.";

View File

@ -1,8 +1,7 @@
{pkgs, config, ...}:
let
inherit (builtins) head tail;
inherit (pkgs.lib) mkOption optionals filter concatMap concatMapStrings;
inherit (pkgs.lib) mkOption mergeOneOption optionals filter concatMap concatMapStrings;
cfg = config.services.xserver;
xorg = cfg.package;
@ -159,11 +158,7 @@ in
the display manager start the xserver.
";
merge = name: list:
if tail list != [] then
throw "only one display manager is allowed."
else
head list;
merge = mergeOneOption;
};
};

View File

@ -1,8 +1,7 @@
{pkgs, config, ...}:
let
inherit (builtins) head tail;
inherit (pkgs.lib) mkOption any;
inherit (pkgs.lib) mkOption mergeOneOption any;
cfg = config.services.xserver.windowManager;
in
@ -47,10 +46,8 @@ in
Default window manager loaded if none have been chosen.
";
merge = name: list:
let defaultWM = head list; in
if tail list != [] then
throw "Only one default window manager is allowed."
else if any (w: w.name == defaultWM) cfg.session then
let defaultWM = mergeOneOption name list; in
if any (w: w.name == defaultWM) cfg.session then
defaultWM
else
throw "Default window manager not found.";