lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #25304 from copumpkin/check-meta

stdenv-generic: add meta attribute checking

authored by

Daniel Peebles and committed by
GitHub
76137a80 ce6eb0cb

+31
+31
pkgs/stdenv/generic/default.nix
··· 18 18 19 19 let 20 20 21 + shouldCheckMeta = config.checkMeta or false; 22 + 21 23 allowUnfree = config.allowUnfree or false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1"; 22 24 23 25 whitelist = config.whitelistedLicenses or []; ··· 151 153 broken = remediate_whitelist "Broken"; 152 154 blacklisted = x: ""; 153 155 insecure = remediate_insecure; 156 + unknown-meta = x: ""; 154 157 }; 155 158 remediate_whitelist = allow_attr: attrs: 156 159 '' ··· 202 205 203 206 '' + ((builtins.getAttr reason remediation) attrs)); 204 207 208 + metaTypes = with lib.types; { 209 + # These keys are documented 210 + description = str; 211 + longDescription = str; 212 + branch = str; 213 + homepage = str; 214 + downloadPage = str; 215 + license = either (listOf lib.types.attrs) lib.types.attrs; 216 + maintainers = listOf str; 217 + priority = int; 218 + platforms = listOf str; 219 + hydraPlatforms = listOf str; 220 + broken = bool; 221 + 222 + # Weirder stuff that doesn't appear in the documentation? 223 + version = str; 224 + updateWalker = bool; 225 + executables = listOf str; 226 + }; 227 + 228 + checkMetaAttr = k: v: 229 + if metaTypes?${k} then 230 + if metaTypes.${k}.check v then null else "key '${k}' has a value of an invalid type; expected ${metaTypes.${k}.description}" 231 + else "key '${k}' is unrecognized; expected one of: \n\t [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]"; 232 + checkMeta = meta: if shouldCheckMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else []; 233 + 205 234 # Check if a derivation is valid, that is whether it passes checks for 206 235 # e.g brokenness or license. 207 236 # ··· 219 248 { valid = false; reason = "broken"; errormsg = "is not supported on ‘${result.system}’"; } 220 249 else if !(hasAllowedInsecure attrs) then 221 250 { valid = false; reason = "insecure"; errormsg = "is marked as insecure"; } 251 + else let res = checkMeta (attrs.meta or {}); in if res != [] then 252 + { valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; } 222 253 else { valid = true; }; 223 254 224 255 outputs' =