Set more precise meta.position for Haskell packages

This commit is contained in:
Eelco Dolstra 2015-03-27 16:11:18 +01:00
parent 8b2f209838
commit 5c0eb64d43
2 changed files with 15 additions and 12 deletions

View File

@ -43,7 +43,7 @@
, preFixup ? "", postFixup ? "" , preFixup ? "", postFixup ? ""
, coreSetup ? false # Use only core packages to build Setup.hs. , coreSetup ? false # Use only core packages to build Setup.hs.
, useCpphs ? false , useCpphs ? false
}: } @ args:
assert pkgconfigDepends != [] -> pkgconfig != null; assert pkgconfigDepends != [] -> pkgconfig != null;
assert editedCabalFile != null -> revision != null; assert editedCabalFile != null -> revision != null;
@ -112,6 +112,8 @@ in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
name = "${optionalString hasActiveLibrary "haskell-"}${pname}-${version}"; name = "${optionalString hasActiveLibrary "haskell-"}${pname}-${version}";
pos = builtins.unsafeGetAttrPos "pname" args;
prePhases = ["setupCompilerEnvironmentPhase"]; prePhases = ["setupCompilerEnvironmentPhase"];
preConfigurePhases = ["compileBuildDriverPhase"]; preConfigurePhases = ["compileBuildDriverPhase"];
preInstallPhases = ["haddockPhase"]; preInstallPhases = ["haddockPhase"];

View File

@ -69,8 +69,6 @@ let
isUnfree (lib.lists.toList attrs.meta.license) && isUnfree (lib.lists.toList attrs.meta.license) &&
!allowUnfreePredicate attrs; !allowUnfreePredicate attrs;
unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
defaultNativeBuildInputs = extraBuildInputs ++ defaultNativeBuildInputs = extraBuildInputs ++
[ ../../build-support/setup-hooks/move-docs.sh [ ../../build-support/setup-hooks/move-docs.sh
../../build-support/setup-hooks/compress-man-pages.sh ../../build-support/setup-hooks/compress-man-pages.sh
@ -91,19 +89,22 @@ let
, crossConfig ? null , crossConfig ? null
, meta ? {} , meta ? {}
, passthru ? {} , passthru ? {}
, pos ? null # position used in error messages and for meta.position
, ... } @ attrs: , ... } @ attrs:
let let
pos = pos' =
if attrs.meta.description or null != null then if pos != null then
unsafeGetAttrPos "description" attrs.meta pos
else if attrs.meta.description or null != null then
builtins.unsafeGetAttrPos "description" attrs.meta
else else
unsafeGetAttrPos "name" attrs; builtins.unsafeGetAttrPos "name" attrs;
pos' = if pos != null then "" + pos.file + ":" + toString pos.line + "" else "«unknown-file»"; pos'' = if pos' != null then "" + pos'.file + ":" + toString pos'.line + "" else "«unknown-file»";
throwEvalHelp = unfreeOrBroken: whatIsWrong: throwEvalHelp = unfreeOrBroken: whatIsWrong:
assert builtins.elem unfreeOrBroken ["Unfree" "Broken" "blacklisted"]; 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") '' + (lib.strings.optionalString (unfreeOrBroken != "blacklisted") ''
For `nixos-rebuild` you can set For `nixos-rebuild` you can set
@ -129,7 +130,7 @@ let
assert licenseAllowed attrs; assert licenseAllowed attrs;
lib.addPassthru (derivation ( lib.addPassthru (derivation (
(removeAttrs attrs ["meta" "passthru" "crossAttrs"]) (removeAttrs attrs ["meta" "passthru" "crossAttrs" "pos"])
// //
{ {
builder = attrs.realBuilder or shell; builder = attrs.realBuilder or shell;
@ -154,8 +155,8 @@ let
# include it in the result, it *is* available to nix-env for # include it in the result, it *is* available to nix-env for
# queries. We also a meta.position attribute here to # queries. We also a meta.position attribute here to
# identify the source location of the package. # identify the source location of the package.
meta = meta // (if pos != null then { meta = meta // (if pos' != null then {
position = pos.file + ":" + toString pos.line; position = pos'.file + ":" + toString pos'.line;
} else {}); } else {});
inherit passthru; inherit passthru;
} // } //