nixpkgs/pkgs/development/tools/haskell/ihaskell/wrapper.nix

29 lines
1.1 KiB
Nix
Raw Normal View History

{ stdenv, writeScriptBin, makeWrapper, buildEnv, haskell, ghcWithPackages, jupyter, packages }:
let
ihaskellEnv = ghcWithPackages (self: [
self.ihaskell
2017-11-06 06:29:56 +00:00
(haskell.lib.doJailbreak self.ihaskell-blaze)
(haskell.lib.doJailbreak self.ihaskell-diagrams)
(haskell.lib.doJailbreak self.ihaskell-display)
] ++ packages self);
2015-04-15 21:59:07 +01:00
ihaskellSh = writeScriptBin "ihaskell-notebook" ''
#! ${stdenv.shell}
2015-04-15 21:59:07 +01:00
export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH"
export PATH="${stdenv.lib.makeBinPath ([ ihaskellEnv jupyter ])}\${PATH:+':'}$PATH"
${ihaskellEnv}/bin/ihaskell install -l $(${ihaskellEnv}/bin/ghc --print-libdir) && ${jupyter}/bin/jupyter notebook
2015-04-15 21:59:07 +01:00
'';
in
buildEnv {
name = "ihaskell-with-packages";
2017-11-06 06:29:56 +00:00
buildInputs = [ makeWrapper ];
paths = [ ihaskellEnv jupyter ];
2015-04-15 21:59:07 +01:00
postBuild = ''
2017-11-06 06:29:56 +00:00
ln -s ${ihaskellSh}/bin/ihaskell-notebook $out/bin/
for prg in $out/bin"/"*;do
2017-11-06 06:29:56 +00:00
if [[ -f $prg && -x $prg ]]; then
wrapProgram $prg --set PYTHONPATH "$(echo ${jupyter}/lib/*/site-packages)"
fi
done
2015-04-15 21:59:07 +01:00
'';
}