diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-03-27 16:11:18 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-03-27 16:17:48 +0100 |
commit | 5c0eb64d4312737f34b9f766f1836a6e75878251 (patch) | |
tree | a4b6b62f152deeebb8bc7f9a720418d916956074 | |
parent | 8b2f209838668ead093dec603bdfdb0347a69a07 (diff) |
Set more precise meta.position for Haskell packages
-rw-r--r-- | pkgs/development/haskell-modules/generic-builder.nix | 4 | ||||
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 23 |
2 files changed, 15 insertions, 12 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 4b0ddaf991c73..3e9f82db359fa 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -43,7 +43,7 @@ , preFixup ? "", postFixup ? "" , coreSetup ? false # Use only core packages to build Setup.hs. , useCpphs ? false -}: +} @ args: assert pkgconfigDepends != [] -> pkgconfig != null; assert editedCabalFile != null -> revision != null; @@ -112,6 +112,8 @@ in stdenv.mkDerivation ({ name = "${optionalString hasActiveLibrary "haskell-"}${pname}-${version}"; + pos = builtins.unsafeGetAttrPos "pname" args; + prePhases = ["setupCompilerEnvironmentPhase"]; preConfigurePhases = ["compileBuildDriverPhase"]; preInstallPhases = ["haddockPhase"]; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index a53ccc3b60a49..6960c84ba5e30 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -69,8 +69,6 @@ let isUnfree (lib.lists.toList attrs.meta.license) && !allowUnfreePredicate attrs; - unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null); - defaultNativeBuildInputs = extraBuildInputs ++ [ ../../build-support/setup-hooks/move-docs.sh ../../build-support/setup-hooks/compress-man-pages.sh @@ -91,19 +89,22 @@ let , crossConfig ? null , meta ? {} , passthru ? {} + , pos ? null # position used in error messages and for meta.position , ... } @ attrs: let - pos = - if attrs.meta.description or null != null then - unsafeGetAttrPos "description" attrs.meta + pos' = + if pos != null then + pos + else if attrs.meta.description or null != null then + builtins.unsafeGetAttrPos "description" attrs.meta else - unsafeGetAttrPos "name" attrs; - pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; + builtins.unsafeGetAttrPos "name" attrs; + pos'' = if pos' != null then "‘" + pos'.file + ":" + toString pos'.line + "’" else "«unknown-file»"; throwEvalHelp = unfreeOrBroken: whatIsWrong: assert builtins.elem unfreeOrBroken ["Unfree" "Broken" "blacklisted"]; - throw ("Package ‘${attrs.name or "«name-missing»"}’ in ${pos'} ${whatIsWrong}, refusing to evaluate." + throw ("Package ‘${attrs.name or "«name-missing»"}’ in ${pos''} ${whatIsWrong}, refusing to evaluate." + (lib.strings.optionalString (unfreeOrBroken != "blacklisted") '' For `nixos-rebuild` you can set @@ -129,7 +130,7 @@ let assert licenseAllowed attrs; lib.addPassthru (derivation ( - (removeAttrs attrs ["meta" "passthru" "crossAttrs"]) + (removeAttrs attrs ["meta" "passthru" "crossAttrs" "pos"]) // { builder = attrs.realBuilder or shell; @@ -154,8 +155,8 @@ let # include it in the result, it *is* available to nix-env for # queries. We also a meta.position attribute here to # identify the source location of the package. - meta = meta // (if pos != null then { - position = pos.file + ":" + toString pos.line; + meta = meta // (if pos' != null then { + position = pos'.file + ":" + toString pos'.line; } else {}); inherit passthru; } // |