Convert assertion option into mkAssert.

svn path=/nixos/trunk/; revision=26614
This commit is contained in:
Nicolas Pierron 2011-03-30 17:52:34 +00:00
parent 87a2c6d9c5
commit 96fc9379ba
7 changed files with 47 additions and 63 deletions

View file

@ -74,14 +74,13 @@ in
###### implementation
config = {
config =
mkAssert
(cfg.client.enable || cfg.server.enable -> config.services.portmap.enable) "
Please enable portmap (services.portmap.enable) to use nfs-kernel.
" {
services.portmap.enable = cfg.client.enable || cfg.server.enable;
assertions = mkIf (cfg.client.enable || cfg.server.enable) (singleton
{ assertion = cfg.client.enable || cfg.server.enable;
message = "Please enable portmap (services.portmap.enable) to use nfs-kernel.";
});
services.portmap.enable = mkAlways (cfg.client.enable || cfg.server.enable);
environment.etc = mkIf cfg.server.enable (singleton
{ source = exports;

View file

@ -42,12 +42,10 @@ in
###### implementation
config = mkIf config.services.openfire.enable {
assertions = singleton
{ assertion = !(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable);
message = "openfire assertion failed";
};
config = mkIf config.services.openfire.enable (
mkAssert (!(config.services.openfire.usePostgreSQL -> config.services.postgresql.enable)) "
openfire assertion failed
" {
jobs.openfire =
{ description = "OpenFire XMPP server";
@ -69,6 +67,6 @@ in
''; # */
};
};
});
}

View file

@ -218,12 +218,10 @@ in
###### implementation
config = mkIf (cfg.client.enable || cfg.relay.enable) {
assertions = [ {
assertion = cfg.relay.enable -> !(cfg.relay.isBridge && cfg.relay.isExit);
message = "Can't be both an exit and a bridge relay at the same time";
} ];
config = mkIf (cfg.client.enable || cfg.relay.enable) (
mkAssert (cfg.relay.enable -> !(cfg.relay.isBridge && cfg.relay.isExit)) "
Can't be both an exit and a bridge relay at the same time
" {
users.extraUsers = singleton
{ name = torUser;
@ -308,6 +306,6 @@ in
# Extra config goes here
'';
};
});
}

View file

@ -33,12 +33,10 @@ in
###### implementation
config = mkIf config.services.xfs.enable {
assertions = singleton
{ assertion = config.fonts.enableFontDir;
message = "Please enable fontDir (fonts.enableFontDir) to use xfs.";
};
config = mkIf config.services.xfs.enable (
mkAssert config.fonts.enableFontDir "
Please enable fontDir (fonts.enableFontDir) to use xfs.
" {
jobs.xfs =
{ description = "X Font Server";
@ -48,6 +46,6 @@ in
exec = "${pkgs.xorg.xfs}/bin/xfs -config ${configFile}";
};
};
});
}

View file

@ -328,23 +328,18 @@ in
###### implementation
config = mkIf cfg.enable {
assertions =
[ { assertion = config.services.hal.enable == true;
message = "The X server needs HAL running. Set services.hal.enable to true";
}
{ assertion = if cfg.startOpenSSHAgent
then !cfg.startGnuPGAgent
else (if cfg.startGnuPGAgent
then !cfg.startOpenSSHAgent
else true);
message =
"The OpenSSH agent and GnuPG agent cannot be started both. " +
"Choose between `startOpenSSHAgent' and `startGnuPGAgent'.";
}
];
config = mkIf cfg.enable (
mkAssert (config.services.hal.enable == true) "
The X server needs HAL running. Set services.hal.enable to true
" (
mkAssert (if cfg.startOpenSSHAgent
then !cfg.startGnuPGAgent
else (if cfg.startGnuPGAgent
then !cfg.startOpenSSHAgent
else true)) "
The OpenSSH agent and GnuPG agent cannot be started both.
Choose between `startOpenSSHAgent' and `startGnuPGAgent'.
" {
boot.extraModulePackages =
optional (elem "nvidia" driverNames) kernelPackages.nvidia_x11 ++
@ -385,7 +380,8 @@ in
environment.pathsToLink =
[ "/etc/xdg" "/share/xdg" "/share/applications" "/share/icons" "/share/pixmaps" ];
services.hal.enable = mkAlways cfg.enable;
services.hal.packages = optional (elem "virtualbox" driverNames) kernelPackages.virtualboxGuestAdditions;
jobs.xserver =
@ -538,6 +534,6 @@ in
'')}
'';
};
}));
}

View file

@ -82,13 +82,11 @@ in
###### implementation
config = mkIf config.services.ttyBackgrounds.enable {
assertions = singleton
{ assertion = kernelPackages.splashutils != null;
message = "The kernelPackages does not provide splashutils, as required by ttyBackgrounds. " +
"Either provide kernelPackages with splashutils, or disable ttyBackgrounds.";
};
config = mkIf config.services.ttyBackgrounds.enable (
mkAssert (kernelPackages.splashutils != null) "
The kernelPackages does not provide splashutils, as required by ttyBackgrounds.
Either provide kernelPackages with splashutils, or disable ttyBackgrounds.
" {
services.ttyBackgrounds.specificThemes = singleton
{ tty = config.services.syslogd.tty;
@ -145,6 +143,6 @@ in
'';
};
};
});
}

View file

@ -21,7 +21,11 @@ in
{
config = {
config =
# Require a patch to the kernel to increase the 15s CIFS timeout.
mkAssert (config.boot.kernelPackages.kernel.features ? cifsTimeout) "
VM tests require that the kernel has the CIFS timeout patch.
" {
jobs.backdoor =
{ startOn = "startup";
@ -95,13 +99,6 @@ in
networking.defaultGateway = mkOverride 150 "";
networking.nameservers = mkOverride 150 [ ];
# Require a patch to the kernel to increase the 15s CIFS timeout.
assertions =
[ { assertion = config.boot.kernelPackages.kernel.features ? cifsTimeout;
message = "VM tests require that the kernel has the CIFS timeout patch.";
}
];
system.upstartEnvironment.GCOV_PREFIX = "/tmp/coverage-data";
};