Use the "assertions" option instead of mkAssert

This commit is contained in:
Eelco Dolstra 2013-10-30 18:30:23 +01:00
parent c7171b2c8f
commit 244cf195c8
5 changed files with 52 additions and 40 deletions

View File

@ -45,9 +45,12 @@ with pkgs.lib;
###### implementation
config = mkIf cfg.enable (
mkAssert (cfg.enable -> cfg.database != "")
"Must specify database name" {
config = mkIf cfg.enable {
assertions = singleton
{ assertion = cfg.enable -> cfg.database != "";
message = "Must specify 4Store database name";
};
users.extraUsers = singleton
{ name = endpointUser;
@ -67,6 +70,6 @@ with pkgs.lib;
'';
};
});
};
}

View File

@ -36,9 +36,12 @@ with pkgs.lib;
###### implementation
config = mkIf cfg.enable (
mkAssert (cfg.enable -> cfg.database != "")
"Must specify database name" {
config = mkIf cfg.enable {
assertions = singleton
{ assertion = cfg.enable -> cfg.database != "";
message = "Must specify 4Store database name.";
};
users.extraUsers = singleton
{ name = fourStoreUser;
@ -66,6 +69,6 @@ with pkgs.lib;
'';
};
});
};
}

View File

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

View File

@ -227,10 +227,12 @@ in
###### implementation
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
" {
config = mkIf (cfg.client.enable || cfg.relay.enable) {
assertions = singleton
{ 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
{ name = torUser;
@ -316,6 +318,6 @@ in
# Extra config goes here
'';
});
};
}

View File

@ -108,17 +108,6 @@ let
''; # */
};
checkAgent = mkAssert (!(cfg.startOpenSSHAgent && cfg.startGnuPGAgent))
''
The OpenSSH agent and GnuPG agent cannot be started both.
Choose between `startOpenSSHAgent' and `startGnuPGAgent'.
'';
checkPolkit = mkAssert config.security.polkit.enable
"X11 requires Polkit to be enabled (security.polkit.enable = true).";
in
{
@ -425,7 +414,20 @@ in
###### implementation
config = mkIf cfg.enable (checkAgent (checkPolkit {
config = mkIf cfg.enable {
assertions =
[ { assertion = !(cfg.startOpenSSHAgent && cfg.startGnuPGAgent);
message =
''
The OpenSSH agent and GnuPG agent cannot be started both.
Choose between `startOpenSSHAgent' and `startGnuPGAgent'.
'';
}
{ assertion = config.security.polkit.enable;
message = "X11 requires Polkit to be enabled (security.polkit.enable = true).";
}
];
boot.extraModulePackages =
optional (elem "nvidia" driverNames) kernelPackages.nvidia_x11 ++
@ -669,7 +671,7 @@ in
${xrandrMonitorSections}
'';
}));
};
}