/
shell.nix
55 lines (51 loc) · 1.22 KB
/
shell.nix
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ with-jupyter ? true }:
let
pkgs = import ./nix {};
ROOT = builtins.toString ./.;
ihaskell = pkgs.ihaskellWithPackages (ps:
[ ps.cio ps.conduit ps.conduit-combinators ]);
functions =
[
''
cio_ghci() {
pushd ${ROOT}/cio
cabal new-repl
popd
}
cio_build() {
pushd ${ROOT}/cio
cabal new-build
popd
}
''
] ++ pkgs.lib.optional with-jupyter
''
cio_notebook() {
ihaskell-notebook
}
cio_readme_gen() {
jupyter-nbconvert \
--to markdown \
${ROOT}/README.ipynb \
--stdout \
> README.md
}
'';
in pkgs.haskellPackages.shellFor
{
packages = p: [ p.cio ];
withHoogle = false;
buildInputs =
[ pkgs.cabal-install ] ++ pkgs.lib.optional with-jupyter ihaskell ;
shellHook =
pkgs.lib.strings.concatStringsSep "\n"
(
[''local pre_functions=$(declare -F | cut -d" " -f3-)'']
++ functions ++
[''
local post_functions=$(declare -F | cut -d" " -f3-)
echo "helpers:"
diff <(echo "$pre_functions") <(echo "$post_functions") | grep '> '
'']
);
}