stdenv: allow specifying a eval issuee handler

This commit is contained in:
Graham Christensen 2017-12-12 18:06:55 -05:00
parent 3a110ea3f9
commit f33a513d2b
No known key found for this signature in database
GPG Key ID: ACA1C1D120C83D5C

View File

@ -125,11 +125,18 @@ let
'';
throwEvalHelp = { reason , errormsg ? "" }:
(if reason != "unknown-meta" then throw else (x : builtins.trace x true)) (''
Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate.
handleEvalIssue = { reason , errormsg ? "" }:
let
msg = ''
Package ${attrs.name or "«name-missing»"} in ${pos_str} ${errormsg}, refusing to evaluate.
'' + (builtins.getAttr reason remediation) attrs;
handler = if config ? "handleEvalIssue"
then config.handleEvalIssue reason
else throw;
in handler msg;
'' + ((builtins.getAttr reason remediation) attrs));
metaTypes = with lib.types; rec {
# These keys are documented
@ -192,7 +199,7 @@ let
validityCondition =
let v = checkValidity attrs;
in if !v.valid
then throwEvalHelp (removeAttrs v ["valid"])
then handleEvalIssue (removeAttrs v ["valid"])
else true;
in