biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / haskell / ihaskell / wrapper.nix
blobb5ea07dde147af320a97e3e61a97c051f8fcda80
1 { lib, stdenv, writeScriptBin, makeWrapper, buildEnv, haskell, ghcWithPackages, jupyter, packages }:
2 let
3   ihaskellEnv = ghcWithPackages (self: [
4     self.ihaskell
5     self.ihaskell-blaze
6     # Doesn't work with latest ihaskell versions missing an unrelated change
7     # https://github.com/IHaskell/IHaskell/issues/1378
8     # self.ihaskell-diagrams
9   ] ++ packages self);
10   ihaskellSh = writeScriptBin "ihaskell-notebook" ''
11     #! ${stdenv.shell}
12     export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH"
13     export PATH="${lib.makeBinPath ([ ihaskellEnv jupyter ])}''${PATH:+:}$PATH"
14     ${ihaskellEnv}/bin/ihaskell install -l $(${ihaskellEnv}/bin/ghc --print-libdir) && ${jupyter}/bin/jupyter notebook
15   '';
17 buildEnv {
18   name = "ihaskell-with-packages";
19   nativeBuildInputs = [ makeWrapper ];
20   paths = [ ihaskellEnv jupyter ];
21   postBuild = ''
22     ln -s ${ihaskellSh}/bin/ihaskell-notebook $out/bin/
23     for prg in $out/bin"/"*;do
24       if [[ -f $prg && -x $prg ]]; then
25         wrapProgram $prg --set PYTHONPATH "$(echo ${jupyter}/lib/*/site-packages)"
26       fi
27     done
28   '';