Convert module which are declaring options into modules separated with an

"options" set to declare options and a "config" set to define options.

svn path=/nixos/trunk/; revision=17148
This commit is contained in:
Nicolas Pierron 2009-09-15 08:33:45 +00:00
parent 81ec373e1e
commit 36573e5e5c
4 changed files with 107 additions and 109 deletions

View File

@ -1,11 +1,13 @@
{pkgs, ...}: {pkgs, ...}:
{ {
environment.checkConfigurationOptions = pkgs.lib.mkOption { options = {
default = true; environment.checkConfigurationOptions = pkgs.lib.mkOption {
example = false; default = true;
description = '' example = false;
Whether to check the validity of the entire configuration. description = ''
''; Whether to check the validity of the entire configuration.
'';
};
}; };
} }

View File

@ -11,7 +11,7 @@ let
in in
{ {
require = [ imports = [
./kde.nix ./kde.nix
./kde4.nix ./kde4.nix
./gnome.nix ./gnome.nix
@ -19,58 +19,56 @@ in
./none.nix ./none.nix
]; ];
services = { options = {
xserver = { services.xserver.desktopManager = {
displayManager = {
session = cfg.session.list;
};
desktopManager = { session = mkOption {
session = mkOption { default = [];
default = []; example = [{
example = [{ name = "kde";
name = "kde"; bgSupport = true;
bgSupport = true; start = "...";
start = "..."; }];
}]; description = "
description = " Internal option used to add some common line to desktop manager
Internal option used to add some common line to desktop manager scripts before forwarding the value to the
scripts before forwarding the value to the <varname>displayManager</varname>.
<varname>displayManager</varname>. ";
"; apply = list: {
apply = list: { list = map (d: d // {
list = map (d: d // { manage = "desktop";
manage = "desktop"; start = d.start
start = d.start + optionalString (needBGCond d) ''
+ optionalString (needBGCond d) '' if test -e $HOME/.background-image; then
if test -e $HOME/.background-image; then ${pkgs.feh}/bin/feh --bg-scale $HOME/.background-image
${pkgs.feh}/bin/feh --bg-scale $HOME/.background-image fi
fi '';
''; }) list;
}) list; needBGPackages = [] != filter needBGCond list;
needBGPackages = [] != filter needBGCond list;
};
};
default = mkOption {
default = "xterm";
example = "none";
description = "
Default desktop manager loaded if none have been chosen.
";
merge = mergeOneOption;
apply = defaultDM:
if any (w: w.name == defaultDM) cfg.session.list then
defaultDM
else
throw "Default desktop manager ($(defaultDM)) not found.";
}; };
}; };
default = mkOption {
default = "xterm";
example = "none";
description = "
Default desktop manager loaded if none have been chosen.
";
merge = mergeOneOption;
apply = defaultDM:
if any (w: w.name == defaultDM) cfg.session.list then
defaultDM
else
throw "Default desktop manager ($(defaultDM)) not found.";
};
}; };
}; };
environment = mkIf cfg.session.needBGPackages { config = {
x11Packages = [ pkgs.feh ]; services.xserver.displayManager.session = cfg.session.list;
environment.x11Packages =
mkIf cfg.session.needBGPackages [ pkgs.feh ];
}; };
} }

View File

@ -6,7 +6,7 @@ let
in in
{ {
require = [ imports = [
./compiz.nix ./compiz.nix
./kwm.nix ./kwm.nix
./metacity.nix ./metacity.nix
@ -16,43 +16,43 @@ in
./xmonad.nix ./xmonad.nix
]; ];
services = { options = {
xserver = { services.xserver.windowManager = {
displayManager = {
session = cfg.session; session = mkOption {
default = [];
example = [{
name = "wmii";
start = "...";
}];
description = "
Internal option used to add some common line to window manager
scripts before forwarding the value to the
<varname>displayManager</varname>.
";
apply = map (d: d // {
manage = "window";
});
}; };
windowManager = { default = mkOption {
session = mkOption { default = "none";
default = []; example = "wmii";
example = [{ description = "
name = "wmii"; Default window manager loaded if none have been chosen.
start = "..."; ";
}]; merge = mergeOneOption;
description = " apply = defaultWM:
Internal option used to add some common line to window manager if any (w: w.name == defaultWM) cfg.session then
scripts before forwarding the value to the defaultWM
<varname>displayManager</varname>. else
"; throw "Default window manager (${defaultWM}) not found.";
apply = map (d: d // {
manage = "window";
});
};
default = mkOption {
default = "none";
example = "wmii";
description = "
Default window manager loaded if none have been chosen.
";
merge = mergeOneOption;
apply = defaultWM:
if any (w: w.name == defaultWM) cfg.session then
defaultWM
else
throw "Default window manager (${defaultWM}) not found.";
};
}; };
}; };
}; };
config = {
services.xserver.displayManager.session = cfg.session;
};
} }

View File

@ -6,27 +6,25 @@ let
in in
{ {
services = { options = {
xserver = { services.xserver.windowManager.xmonad = {
enable = mkOption {
windowManager = { default = false;
xmonad = { example = true;
enable = mkOption { description = "Enable the xmonad window manager.";
default = false;
example = true;
description = "Enable the xmonad window manager.";
};
};
session = mkIf cfg.enable [{
name = "xmonad";
start = "
${pkgs.haskellPackages.xmonad}/bin/xmonad &
waitPID=$!
";
}];
}; };
};
};
config = {
services.xserver.windowManager = {
session = mkIf cfg.enable [{
name = "xmonad";
start = "
${pkgs.haskellPackages.xmonad}/bin/xmonad &
waitPID=$!
";
}];
}; };
}; };
} }