From 89b5d9ee14a328b26fedf40b48f599959ae8d780 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Sat, 10 Jan 2015 13:23:04 +0100 Subject: [PATCH] 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 --- .../haskell-modules/generic-builder.nix | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 3ba1a1cabadb..18b3a6af30bf 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -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; }