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, ...}:
{
environment.checkConfigurationOptions = pkgs.lib.mkOption {
default = true;
example = false;
description = ''
Whether to check the validity of the entire configuration.
'';
options = {
environment.checkConfigurationOptions = pkgs.lib.mkOption {
default = true;
example = false;
description = ''
Whether to check the validity of the entire configuration.
'';
};
};
}
}

View File

@ -11,7 +11,7 @@ let
in
{
require = [
imports = [
./kde.nix
./kde4.nix
./gnome.nix
@ -19,58 +19,56 @@ in
./none.nix
];
services = {
xserver = {
displayManager = {
session = cfg.session.list;
};
options = {
services.xserver.desktopManager = {
desktopManager = {
session = mkOption {
default = [];
example = [{
name = "kde";
bgSupport = true;
start = "...";
}];
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;
};
};
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.";
session = mkOption {
default = [];
example = [{
name = "kde";
bgSupport = true;
start = "...";
}];
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;
};
};
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 {
x11Packages = [ pkgs.feh ];
config = {
services.xserver.displayManager.session = cfg.session.list;
environment.x11Packages =
mkIf cfg.session.needBGPackages [ pkgs.feh ];
};
}

View File

@ -6,7 +6,7 @@ let
in
{
require = [
imports = [
./compiz.nix
./kwm.nix
./metacity.nix
@ -16,43 +16,43 @@ in
./xmonad.nix
];
services = {
xserver = {
displayManager = {
session = cfg.session;
options = {
services.xserver.windowManager = {
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 = {
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";
});
};
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.";
};
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
{
services = {
xserver = {
windowManager = {
xmonad = {
enable = mkOption {
default = false;
example = true;
description = "Enable the xmonad window manager.";
};
};
session = mkIf cfg.enable [{
name = "xmonad";
start = "
${pkgs.haskellPackages.xmonad}/bin/xmonad &
waitPID=$!
";
}];
options = {
services.xserver.windowManager.xmonad = {
enable = mkOption {
default = false;
example = true;
description = "Enable the xmonad window manager.";
};
};
};
config = {
services.xserver.windowManager = {
session = mkIf cfg.enable [{
name = "xmonad";
start = "
${pkgs.haskellPackages.xmonad}/bin/xmonad &
waitPID=$!
";
}];
};
};
}