haskell-generic-builder: add an 'env' attribute to every Haskell expression that can be used with nix-shell to create an interactive build environment for this package

For example:

  nix-shell --pure ~/.nix-defexpr -A haskell-ng.packages.ghc784.hsdns.env
This commit is contained in:
Peter Simons 2015-01-10 13:23:04 +01:00
parent f36973ce83
commit 89b5d9ee14

View File

@ -69,6 +69,17 @@ let
sha256 = editedCabalFile;
};
isHaskellPkg = x: (x ? pname) && (x ? version);
isSystemPkg = x: !isHaskellPkg x;
allBuildInputs = stdenv.lib.filter (x: x != null) (
buildDepends ++ extraLibraries ++ buildTools ++
optionals (pkgconfigDepends != []) ([pkgconfig] ++ pkgconfigDepends) ++
optionals doCheck testDepends
);
haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs;
systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs;
in
stdenv.mkDerivation ({
name = "${optionalString hasActiveLibrary "haskell-"}${pname}-${version}";
@ -195,7 +206,17 @@ stdenv.mkDerivation ({
runHook postInstall
'';
passthru = passthru // { inherit pname version; };
passthru = passthru // {
inherit pname version;
env = stdenv.mkDerivation {
name = "interactive-${optionalString hasActiveLibrary "haskell-"}${pname}-${version}-environment";
nativeBuildInputs = [ (ghc.withPackages (p: haskellBuildInputs)) systemBuildInputs ];
shellHook = "eval $(grep export $(type -p ghc))";
};
};
meta = { inherit homepage license platforms hydraPlatforms; }
// optionalAttrs broken { inherit broken; }