* Cleanup.

svn path=/nixos/trunk/; revision=17008
This commit is contained in:
Eelco Dolstra 2009-09-10 13:53:31 +00:00
parent bc95e0fdf9
commit 5d55df7abf
1 changed files with 28 additions and 16 deletions

View File

@ -1,25 +1,37 @@
{pkgs, config, ...}: { config, pkgs, ... }:
with pkgs.lib;
let let
inherit (pkgs.lib) mkOption filter concatMap concatStringsSep;
failed = map (x : x.message) (filter (x: ! x.assertion) config.assertions);
in
failed = map (x: x.message) (filter (x: !x.assertion) config.assertions);
in
{ {
assertions = mkOption { options = {
default = [];
example = [{ assertion = false; msg = "you can't enable this for that reason"; }]; assertions = mkOption {
merge = pkgs.lib.mergeListOption; default = [];
description = '' example = [ { assertion = false; msg = "you can't enable this for that reason"; } ];
Add something like this merge = pkgs.lib.mergeListOption;
assertions = mkAlways [ { assertion = false; message = "false should have been true"; } ]; description = ''
to your upstart-job. This option allows modules to express conditions that must
''; hold for the evaluation of the system configuration to
succeed, along with associated error messages for the user.
'';
};
}; };
environment = { config = {
# extraPackages are evaluated always. Thus the assertions are checked as well. hacky!
extraPackages = if [] == failed then [] else throw "\n!! failed assertions: !!\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}"; # This option is evaluated always. Thus the assertions are checked as well. hacky!
environment.systemPackages =
if [] == failed then []
else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}";
}; };
} }