stdenv: simple refactor to get rid of pos'

Suggested by Ericson2314.

authored by Vladimír Čunát and committed by John Ericson 5afcdc88 7fdf18e8

+9 -14
+9 -14
pkgs/stdenv/generic/default.nix
··· 135 , crossConfig ? null 136 , meta ? {} 137 , passthru ? {} 138 - , pos ? null # position used in error messages and for meta.position 139 , separateDebugInfo ? false 140 , outputs ? [ "out" ] 141 , __impureHostDeps ? [] ··· 153 (map (drv: drv.crossDrv or drv) propagatedBuildInputs) 154 ]; 155 in let 156 - pos' = 157 - if pos != null then 158 - pos 159 - else if attrs.meta.description or null != null then 160 - builtins.unsafeGetAttrPos "description" attrs.meta 161 - else 162 - builtins.unsafeGetAttrPos "name" attrs; 163 - pos'' = if pos' != null then "‘" + pos'.file + ":" + toString pos'.line + "’" else "«unknown-file»"; 164 - 165 166 remediation = { 167 unfree = remediate_whitelist "Unfree"; ··· 216 217 throwEvalHelp = { reason , errormsg ? "" }: 218 throw ('' 219 - Package ‘${attrs.name or "«name-missing»"}’ in ${pos''} ${errormsg}, refusing to evaluate. 220 221 '' + ((builtins.getAttr reason remediation) attrs)); 222 ··· 293 294 # Throw an error if trying to evaluate an non-valid derivation 295 validityCondition = 296 - let v = checkValidity attrs; 297 in if !v.valid 298 then throwEvalHelp (removeAttrs v ["valid"]) 299 else true; ··· 364 } 365 // attrs.meta or {} 366 # Fill `meta.position` to identify the source location of the package. 367 - // lib.optionalAttrs (pos' != null) 368 - { position = pos'.file + ":" + toString pos'.line; } 369 ; 370 371 in
··· 135 , crossConfig ? null 136 , meta ? {} 137 , passthru ? {} 138 + , pos ? # position used in error messages and for meta.position 139 + (if attrs.meta.description or null != null 140 + then builtins.unsafeGetAttrPos "description" attrs.meta 141 + else builtins.unsafeGetAttrPos "name" attrs) 142 , separateDebugInfo ? false 143 , outputs ? [ "out" ] 144 , __impureHostDeps ? [] ··· 156 (map (drv: drv.crossDrv or drv) propagatedBuildInputs) 157 ]; 158 in let 159 + pos_str = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; 160 161 remediation = { 162 unfree = remediate_whitelist "Unfree"; ··· 211 212 throwEvalHelp = { reason , errormsg ? "" }: 213 throw ('' 214 + Package ‘${attrs.name or "«name-missing»"}’ in ${pos_str} ${errormsg}, refusing to evaluate. 215 216 '' + ((builtins.getAttr reason remediation) attrs)); 217 ··· 288 289 # Throw an error if trying to evaluate an non-valid derivation 290 validityCondition = 291 + let v = checkValidity attrs; 292 in if !v.valid 293 then throwEvalHelp (removeAttrs v ["valid"]) 294 else true; ··· 359 } 360 // attrs.meta or {} 361 # Fill `meta.position` to identify the source location of the package. 362 + // lib.optionalAttrs (pos != null) 363 + { position = pos.file + ":" + toString pos.line; } 364 ; 365 366 in