mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-19 20:09:01 +02:00
Merge pull request #297353 from adisbladis/check-meta-validity-only
stdenv/check-meta: Make `checkValidity` only check validity
This commit is contained in:
commit
509577b789
|
@ -390,22 +390,24 @@ let
|
||||||
# reason is one of "unfree", "blocklisted", "broken", "insecure", ...
|
# reason is one of "unfree", "blocklisted", "broken", "insecure", ...
|
||||||
# !!! reason strings are hardcoded into OfBorg, make sure to keep them in sync
|
# !!! reason strings are hardcoded into OfBorg, make sure to keep them in sync
|
||||||
# Along with a boolean flag for each reason
|
# Along with a boolean flag for each reason
|
||||||
checkValidity = attrs:
|
checkValidity =
|
||||||
|
let
|
||||||
|
validYes = {
|
||||||
|
valid = "yes";
|
||||||
|
handled = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
attrs:
|
||||||
# Check meta attribute types first, to make sure it is always called even when there are other issues
|
# Check meta attribute types first, to make sure it is always called even when there are other issues
|
||||||
# Note that this is not a full type check and functions below still need to by careful about their inputs!
|
# Note that this is not a full type check and functions below still need to by careful about their inputs!
|
||||||
let res = checkMeta (attrs.meta or {}); in if res != [] then
|
let
|
||||||
{ valid = "no"; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${concatMapStrings (x: "\n - " + x) res}\n";
|
res = checkMeta (attrs.meta or {});
|
||||||
unfree = false; nonSource = false; broken = false; unsupported = false; insecure = false;
|
in
|
||||||
}
|
if res != [] then
|
||||||
else {
|
{ valid = "no"; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${concatMapStrings (x: "\n - " + x) res}\n"; }
|
||||||
unfree = hasUnfreeLicense attrs;
|
|
||||||
nonSource = hasNonSourceProvenance attrs;
|
|
||||||
broken = isMarkedBroken attrs;
|
|
||||||
unsupported = hasUnsupportedPlatform attrs;
|
|
||||||
insecure = isMarkedInsecure attrs;
|
|
||||||
} // (
|
|
||||||
# --- Put checks that cannot be ignored here ---
|
# --- Put checks that cannot be ignored here ---
|
||||||
if checkOutputsToInstall attrs then
|
else if checkOutputsToInstall attrs then
|
||||||
{ valid = "no"; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; }
|
{ valid = "no"; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; }
|
||||||
|
|
||||||
# --- Put checks that can be ignored here ---
|
# --- Put checks that can be ignored here ---
|
||||||
|
@ -438,7 +440,7 @@ let
|
||||||
else if hasNoMaintainers attrs then
|
else if hasNoMaintainers attrs then
|
||||||
{ valid = "warn"; reason = "maintainerless"; errormsg = "has no maintainers"; }
|
{ valid = "warn"; reason = "maintainerless"; errormsg = "has no maintainers"; }
|
||||||
# -----
|
# -----
|
||||||
else { valid = "yes"; });
|
else validYes;
|
||||||
|
|
||||||
|
|
||||||
# The meta attribute is passed in the resulting attribute set,
|
# The meta attribute is passed in the resulting attribute set,
|
||||||
|
@ -485,7 +487,10 @@ let
|
||||||
position = pos.file + ":" + toString pos.line;
|
position = pos.file + ":" + toString pos.line;
|
||||||
} // {
|
} // {
|
||||||
# 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;
|
unfree = hasUnfreeLicense attrs;
|
||||||
|
broken = isMarkedBroken attrs;
|
||||||
|
unsupported = hasUnsupportedPlatform attrs;
|
||||||
|
insecure = isMarkedInsecure attrs;
|
||||||
|
|
||||||
available = validity.valid != "no"
|
available = validity.valid != "no"
|
||||||
&& (if config.checkMetaRecursively or false
|
&& (if config.checkMetaRecursively or false
|
||||||
|
@ -496,7 +501,7 @@ let
|
||||||
assertValidity = { meta, attrs }: let
|
assertValidity = { meta, attrs }: let
|
||||||
validity = checkValidity attrs;
|
validity = checkValidity attrs;
|
||||||
inherit (validity) valid;
|
inherit (validity) valid;
|
||||||
in validity // {
|
in if validity ? handled then validity else validity // {
|
||||||
# Throw an error if trying to evaluate a non-valid derivation
|
# Throw an error if trying to evaluate a non-valid derivation
|
||||||
# or, alternatively, just output a warning message.
|
# or, alternatively, just output a warning message.
|
||||||
handled =
|
handled =
|
||||||
|
|
Loading…
Reference in a new issue