From 5afcdc88fa7ce9583eecec136de49685923e8df7 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Sun, 29 Jan 2017 22:12:41 +0100 Subject: stdenv: simple refactor to get rid of pos' Suggested by Ericson2314. --- pkgs/stdenv/generic/default.nix | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'pkgs') diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 8db0017f2d99..065f4fb508de 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -135,7 +135,10 @@ let , crossConfig ? null , meta ? {} , passthru ? {} - , pos ? null # position used in error messages and for meta.position + , pos ? # position used in error messages and for meta.position + (if attrs.meta.description or null != null + then builtins.unsafeGetAttrPos "description" attrs.meta + else builtins.unsafeGetAttrPos "name" attrs) , separateDebugInfo ? false , outputs ? [ "out" ] , __impureHostDeps ? [] @@ -153,15 +156,7 @@ let (map (drv: drv.crossDrv or drv) propagatedBuildInputs) ]; in let - pos' = - if pos != null then - pos - else if attrs.meta.description or null != null then - builtins.unsafeGetAttrPos "description" attrs.meta - else - builtins.unsafeGetAttrPos "name" attrs; - pos'' = if pos' != null then "‘" + pos'.file + ":" + toString pos'.line + "’" else "«unknown-file»"; - + pos_str = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; remediation = { unfree = remediate_whitelist "Unfree"; @@ -216,7 +211,7 @@ let throwEvalHelp = { reason , errormsg ? "" }: throw ('' - Package ‘${attrs.name or "«name-missing»"}’ in ${pos''} ${errormsg}, refusing to evaluate. + Package ‘${attrs.name or "«name-missing»"}’ in ${pos_str} ${errormsg}, refusing to evaluate. '' + ((builtins.getAttr reason remediation) attrs)); @@ -293,7 +288,7 @@ let # Throw an error if trying to evaluate an non-valid derivation validityCondition = - let v = checkValidity attrs; + let v = checkValidity attrs; in if !v.valid then throwEvalHelp (removeAttrs v ["valid"]) else true; @@ -364,8 +359,8 @@ let } // attrs.meta or {} # Fill `meta.position` to identify the source location of the package. - // lib.optionalAttrs (pos' != null) - { position = pos'.file + ":" + toString pos'.line; } + // lib.optionalAttrs (pos != null) + { position = pos.file + ":" + toString pos.line; } ; in -- cgit 1.4.1