mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-29 16:57:40 +03:00
stdenv/check-meta: turn validity.valid into a str
This will allow for adding more validity types in the future, such as a warning type. (which is in the next commit in this series) This is NOT a breaking change because validity.valid is never exposed outside of `stdenv.mkDerivation`.
This commit is contained in:
parent
27103e676a
commit
5e420c2455
@ -277,28 +277,31 @@ let
|
|||||||
insecure = isMarkedInsecure attrs;
|
insecure = isMarkedInsecure attrs;
|
||||||
}
|
}
|
||||||
// (if hasDeniedUnfreeLicense attrs && !(hasAllowlistedLicense attrs) then
|
// (if hasDeniedUnfreeLicense attrs && !(hasAllowlistedLicense attrs) then
|
||||||
{ valid = false; reason = "unfree"; errormsg = "has an unfree license (‘${showLicense attrs.meta.license}’)"; }
|
{ valid = "no"; reason = "unfree"; errormsg = "has an unfree license (‘${showLicense attrs.meta.license}’)"; }
|
||||||
else if hasBlocklistedLicense attrs then
|
else if hasBlocklistedLicense attrs then
|
||||||
{ valid = false; reason = "blocklisted"; errormsg = "has a blocklisted license (‘${showLicense attrs.meta.license}’)"; }
|
{ valid = "no"; reason = "blocklisted"; errormsg = "has a blocklisted license (‘${showLicense attrs.meta.license}’)"; }
|
||||||
else if !allowBroken && attrs.meta.broken or false then
|
else if !allowBroken && attrs.meta.broken or false then
|
||||||
{ valid = false; reason = "broken"; errormsg = "is marked as broken"; }
|
{ valid = "no"; reason = "broken"; errormsg = "is marked as broken"; }
|
||||||
else if !allowUnsupportedSystem && hasUnsupportedPlatform attrs then
|
else if !allowUnsupportedSystem && hasUnsupportedPlatform attrs then
|
||||||
{ valid = false; reason = "unsupported"; errormsg = "is not supported on ‘${hostPlatform.system}’"; }
|
{ valid = "no"; reason = "unsupported"; errormsg = "is not supported on ‘${hostPlatform.system}’"; }
|
||||||
else if !(hasAllowedInsecure attrs) then
|
else if !(hasAllowedInsecure attrs) then
|
||||||
{ valid = false; reason = "insecure"; errormsg = "is marked as insecure"; }
|
{ valid = "no"; reason = "insecure"; errormsg = "is marked as insecure"; }
|
||||||
else if checkOutputsToInstall attrs then
|
else if checkOutputsToInstall attrs then
|
||||||
{ valid = false; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; }
|
{ valid = "no"; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; }
|
||||||
else let res = checkMeta (attrs.meta or {}); in if res != [] then
|
else let res = checkMeta (attrs.meta or {}); in if res != [] then
|
||||||
{ valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
|
{ valid = "no"; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
|
||||||
else { valid = true; });
|
else { valid = "yes"; });
|
||||||
|
|
||||||
assertValidity = { meta, attrs }: let
|
assertValidity = { meta, attrs }: let
|
||||||
validity = checkValidity attrs;
|
validity = checkValidity attrs;
|
||||||
in validity // {
|
in validity // {
|
||||||
# Throw an error if trying to evaluate an non-valid derivation
|
# Throw an error if trying to evaluate a non-valid derivation
|
||||||
handled = if !validity.valid
|
# or, alternatively, just output a warning message.
|
||||||
then handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; }
|
handled =
|
||||||
else true;
|
{
|
||||||
|
no = handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; };
|
||||||
|
yes = true;
|
||||||
|
}.${validity.valid};
|
||||||
};
|
};
|
||||||
|
|
||||||
in assertValidity
|
in assertValidity
|
||||||
|
@ -370,7 +370,7 @@ else let
|
|||||||
} // {
|
} // {
|
||||||
# Expose the result of the checks for everyone to see.
|
# Expose the result of the checks for everyone to see.
|
||||||
inherit (validity) unfree broken unsupported insecure;
|
inherit (validity) unfree broken unsupported insecure;
|
||||||
available = validity.valid
|
available = validity.valid != "no"
|
||||||
&& (if config.checkMetaRecursively or false
|
&& (if config.checkMetaRecursively or false
|
||||||
then lib.all (d: d.meta.available or true) references
|
then lib.all (d: d.meta.available or true) references
|
||||||
else true);
|
else true);
|
||||||
|
Loading…
Reference in New Issue
Block a user