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 ###### 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; services.portmap.enable = mkAlways (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.";
});
environment.etc = mkIf cfg.server.enable (singleton environment.etc = mkIf cfg.server.enable (singleton
{ source = exports; { source = exports;

View File

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

View File

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

View File

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

View File

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

View File

@ -82,13 +82,11 @@ in
###### implementation ###### implementation
config = mkIf config.services.ttyBackgrounds.enable { config = mkIf config.services.ttyBackgrounds.enable (
mkAssert (kernelPackages.splashutils != null) "
assertions = singleton The kernelPackages does not provide splashutils, as required by ttyBackgrounds.
{ assertion = kernelPackages.splashutils != null; Either provide kernelPackages with splashutils, or disable ttyBackgrounds.
message = "The kernelPackages does not provide splashutils, as required by ttyBackgrounds. " + " {
"Either provide kernelPackages with splashutils, or disable ttyBackgrounds.";
};
services.ttyBackgrounds.specificThemes = singleton services.ttyBackgrounds.specificThemes = singleton
{ tty = config.services.syslogd.tty; { 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 = jobs.backdoor =
{ startOn = "startup"; { startOn = "startup";
@ -95,13 +99,6 @@ in
networking.defaultGateway = mkOverride 150 ""; networking.defaultGateway = mkOverride 150 "";
networking.nameservers = 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"; system.upstartEnvironment.GCOV_PREFIX = "/tmp/coverage-data";
}; };