diff options
author | adisbladis <adisbladis@gmail.com> | 2024-03-20 16:48:12 +1300 |
---|---|---|
committer | adisbladis <adisbladis@gmail.com> | 2024-04-03 21:38:43 +1300 |
commit | 000f61a61044f20b53d8c4b11c70008dd98dded9 (patch) | |
tree | 498ca8c763a956493a49dd74c72b4272646edc9e /pkgs/stdenv | |
parent | 213b1a46b6575d065f036056524fddba5d86b7f3 (diff) |
stdenv/check-meta: Make `checkValidity` only check validity
checkValidity has the responsibility to check if a derivation's attributes are valid.
Previously it also had the overloaded task of creating a subset of meta attributes:
- unfree
- broken
- unsupported
- insecure
Not only is this overloading strange, these attributes were only ever consumed by `commonMeta`.
This change makes checkValidity _only_ check for validity, and removes the creation of any meta attributes from `checkValidity` and moves them to `commonMeta`.
This is technically a breaking change but I don't expect any external nixpkgs consumers to rely on these implementation details.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/generic/check-meta.nix | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 1cd1ae6dd72e..bcb2ca249ddf 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -390,22 +390,24 @@ let # reason is one of "unfree", "blocklisted", "broken", "insecure", ... # !!! reason strings are hardcoded into OfBorg, make sure to keep them in sync # 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 # 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 - { valid = "no"; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${concatMapStrings (x: "\n - " + x) res}\n"; - unfree = false; nonSource = false; broken = false; unsupported = false; insecure = false; - } - else { - unfree = hasUnfreeLicense attrs; - nonSource = hasNonSourceProvenance attrs; - broken = isMarkedBroken attrs; - unsupported = hasUnsupportedPlatform attrs; - insecure = isMarkedInsecure attrs; - } // ( + let + res = checkMeta (attrs.meta or {}); + in + if res != [] then + { valid = "no"; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${concatMapStrings (x: "\n - " + x) res}\n"; } + # --- 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"; } # --- Put checks that can be ignored here --- @@ -438,7 +440,7 @@ let else if hasNoMaintainers attrs then { valid = "warn"; reason = "maintainerless"; errormsg = "has no maintainers"; } # ----- - else { valid = "yes"; }); + else validYes; # The meta attribute is passed in the resulting attribute set, @@ -485,7 +487,10 @@ let position = pos.file + ":" + toString pos.line; } // { # 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" && (if config.checkMetaRecursively or false @@ -496,7 +501,7 @@ let assertValidity = { meta, attrs }: let validity = checkValidity attrs; inherit (validity) valid; - in validity // { + in if validity ? handled then validity else validity // { # Throw an error if trying to evaluate a non-valid derivation # or, alternatively, just output a warning message. handled = |