From 6041b78fa45824e23a4db16c6b8e167788a3d179 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sat, 19 Sep 2009 22:10:11 +0000 Subject: [PATCH] Report bad default values which would have cause a build failure if they were used to build a NixOS system. svn path=/nixpkgs/trunk/; revision=17286 --- pkgs/lib/options.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix index b9ed6e2ec6c..c1c6a64d6d5 100644 --- a/pkgs/lib/options.nix +++ b/pkgs/lib/options.nix @@ -235,6 +235,12 @@ rec { # the set generated with filterOptionSets. optionAttrSetToDocList = ignore: newOptionAttrSetToDocList; newOptionAttrSetToDocList = attrs: + let tryEval = v: + let res = builtins.tryEval v; in + if builtins ? tryEval then + if res.success then res.value else "" + else v; + in let options = collect isOption attrs; in fold (opt: rest: let @@ -246,8 +252,8 @@ rec { declarations = map (x: toString x.source) opt.declarations; definitions = map (x: toString x.source) opt.definitions; } - // (if opt ? example then {inherit(opt) example;} else {}) - // (if opt ? default then {inherit(opt) default;} else {}); + // optionalAttrs (opt ? example) { example = tryEval opt.example; } + // optionalAttrs (opt ? default) { default = tryEval opt.default; }; subOptions = if opt ? options then