stdenv/check-meta: add an eval warning option
This will be used in the next commit in this patch series.
This commit is contained in:
parent
5e420c2455
commit
3a34b6c820
2 changed files with 28 additions and 0 deletions
|
@ -7,6 +7,10 @@ let
|
|||
# If we're in hydra, we can dispense with the more verbose error
|
||||
# messages and make problems easier to spot.
|
||||
inHydra = config.inHydra or false;
|
||||
# Allow the user to opt-into additional warnings, e.g.
|
||||
# import <nixpkgs> { config = { showDerivationWarnings = [ "maintainerless" ]; }; }
|
||||
showWarnings = config.showDerivationWarnings;
|
||||
|
||||
getName = attrs: attrs.name or ("${attrs.pname or "«name-missing»"}-${attrs.version or "«version-missing»"}");
|
||||
|
||||
# See discussion at https://github.com/NixOS/nixpkgs/pull/25304#issuecomment-298385426
|
||||
|
@ -199,6 +203,14 @@ let
|
|||
else throw;
|
||||
in handler msg;
|
||||
|
||||
handleEvalWarning = { meta, attrs }: { reason , errormsg ? "" }:
|
||||
let
|
||||
remediationMsg = (builtins.getAttr reason remediation) attrs;
|
||||
msg = if inHydra then "Warning while evaluating ${getName attrs}: «${reason}»: ${errormsg}"
|
||||
else "Package ${getName attrs} in ${pos_str meta} ${errormsg}, continuing anyway."
|
||||
+ (if remediationMsg != "" then "\n${remediationMsg}" else "");
|
||||
isEnabled = lib.findFirst (x: x == reason) null showWarnings;
|
||||
in if isEnabled != null then builtins.trace msg true else true;
|
||||
|
||||
metaTypes = with lib.types; rec {
|
||||
# These keys are documented
|
||||
|
@ -300,6 +312,7 @@ let
|
|||
handled =
|
||||
{
|
||||
no = handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; };
|
||||
warn = handleEvalWarning { inherit meta attrs; } { inherit (validity) reason errormsg; };
|
||||
yes = true;
|
||||
}.${validity.valid};
|
||||
};
|
||||
|
|
|
@ -94,6 +94,21 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
showDerivationWarnings = mkOption {
|
||||
type = types.listOf (types.enum [ "maintainerless" ]);
|
||||
default = [];
|
||||
description = ''
|
||||
Which warnings to display for potentially dangerous
|
||||
or deprecated values passed into `stdenv.mkDerivation`.
|
||||
|
||||
A list of warnings can be found in
|
||||
<link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/check-meta.nix">/pkgs/stdenv/generic/check-meta.nix</link>.
|
||||
|
||||
This is not a stable interface; warnings may be added, changed
|
||||
or removed without prior notice.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
in {
|
||||
|
|
Loading…
Reference in a new issue