waylyrics: 0.3.16 -> 0.3.20 (#364626)
[NixPkgs.git] / pkgs / development / tools / haskell / ihaskell / wrapper.nix
blob14c9ae409c2279a9559a698e5809d4f5ce9d8184
2   lib,
3   stdenv,
4   writeScriptBin,
5   makeWrapper,
6   buildEnv,
7   ghcWithPackages,
8   jupyter,
9   packages,
11 let
12   ihaskellEnv = ghcWithPackages (
13     self:
14     [
15       self.ihaskell
16       self.ihaskell-blaze
17       # Doesn't work with latest ihaskell versions missing an unrelated change
18       # https://github.com/IHaskell/IHaskell/issues/1378
19       # self.ihaskell-diagrams
20     ]
21     ++ packages self
22   );
23   ihaskellSh = writeScriptBin "ihaskell-notebook" ''
24     #! ${stdenv.shell}
25     export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH"
26     export PATH="${
27       lib.makeBinPath ([
28         ihaskellEnv
29         jupyter
30       ])
31     }''${PATH:+:}$PATH"
32     ${ihaskellEnv}/bin/ihaskell install -l $(${ihaskellEnv}/bin/ghc --print-libdir) && ${jupyter}/bin/jupyter notebook
33   '';
35 buildEnv {
36   name = "ihaskell-with-packages";
37   nativeBuildInputs = [ makeWrapper ];
38   paths = [
39     ihaskellEnv
40     jupyter
41   ];
42   postBuild = ''
43     ln -s ${ihaskellSh}/bin/ihaskell-notebook $out/bin/
44     for prg in $out/bin"/"*;do
45       if [[ -f $prg && -x $prg ]]; then
46         wrapProgram $prg --set PYTHONPATH "$(echo ${jupyter}/lib/*/site-packages)"
47       fi
48     done
49   '';