summary refs log tree commit diff
path: root/pkgs/development/tools/haskell/ihaskell/wrapper.nix
blob: 7ec56267f6b3a25e7166d3f10104910e9dedb0b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ stdenv, writeScriptBin, makeWrapper, buildEnv, ghcWithPackages, ihaskell, ipython, packages }:
let
  ihaskellEnv = ghcWithPackages (self: [
    self.ihaskell
    self.ihaskell-blaze
    self.ihaskell-diagrams
    self.ihaskell-display
  ] ++ packages self);
  ihaskellSh = writeScriptBin "ihaskell-notebook" ''
    #! ${stdenv.shell}
    export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH"
    export PATH="${ihaskell}/bin:${ihaskellEnv}/bin:${ipython}/bin"
    ${ihaskell}/bin/ihaskell install -l $(${ihaskellEnv}/bin/ghc --print-libdir) && ${ipython}/bin/ipython notebook --kernel=haskell
  '';
  profile = "${ihaskell.pname}-${ihaskell.version}/profile/profile.tar";
in
buildEnv {
  name = "ihaskell-with-packages";
  paths = [ ihaskellEnv ipython ];
  postBuild = ''
    . "${makeWrapper}/nix-support/setup-hook"
    ln -s ${ihaskellSh}/bin/ihaskell-notebook $out/bin/.
    for prg in $out/bin"/"*;do
      wrapProgram $prg --set PYTHONPATH "$(echo ${ipython}/lib/*/site-packages)"
    done
  '';
}