forked from robots-from-jupyter/robotkernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
162 lines (142 loc) · 5.05 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{ pkgs ? import ./nix {}
, sikuli ? false
, vim ? false
}:
let self = rec {
# python packages
python = (import ./setup.nix {
inherit pkgs;
pythonPackages = pkgs.python3Packages;
}).targetPython;
pythonPackages = python.pkgs;
sikulilibrary = (import ./pkgs/sikulixlibrary {
inherit pkgs pythonPackages;
jdk = pkgs.jdk;
sikulix = with pkgs; import ./pkgs/sikulix {
inherit stdenv fetchurl makeWrapper utillinux jre jdk opencv;
inherit tesseract xdotool wmctrl;
};
});
"robotkernel" = (import ./setup.nix {
inherit pkgs;
pythonPackages = pkgs.python3Packages;
}).package;
# other packages
vim_binding = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "jupyter-vim-binding";
rev = "c9822c753b6acad8b1084086d218eb4ce69950e9";
sha256 = "1951wnf0k91h07nfsz8rr0c9nw68dbyflkjvw5pbx9dmmzsa065j";
};
# jupyter
jupyter = pythonPackages.jupyter.overridePythonAttrs (old: {
propagatedBuildInputs =
with pythonPackages; old.propagatedBuildInputs ++ [
(graphviz.overridePythonAttrs(old: { doCheck = false; }))
iplantuml
ipywidgets
jupytext
jupyter-starters
jupyter-contrib-nbextensions
jupyter-nbextensions-configurator
jupyterlab
jupyterlab-kernelspy
nbimporter
opencv3
RESTinstance
matplotlib
rise
robotframework
# robotframework-appiumlibrary
robotframework-faker
robotframework-seleniumlibrary
robotframework-seleniumtestability
robotframework-seleniumscreenshots
robotframework-jupyterlibrary
robotframework-sshlibrary
robotkernel
tkinter
widgetsnbextension
] ++ pkgs.lib.optionals sikuli [ sikulilibrary ];
});
jupyter_nbconfig = pkgs.stdenv.mkDerivation rec {
name = "jupyter";
json = builtins.toJSON {
load_extensions = {
"jupyter-js-widgets/extension" = true;
"rise/main" = true;
"jupytext/index" = true;
"vim_binding/vim_binding" = if vim then true else false;
};
keys = {
command = {
bind = {
"Ctrl-7" = "RISE:toggle-slide";
"Ctrl-8" = "RISE:toggle-subslide";
"Ctrl-9" = "RISE:toggle-fragment";
};
};
};
};
builder = with pkgs; builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir -p $out
cat > $out/notebook.json << EOF
$json
EOF
'';
};
jupyter_config_dir = pkgs.stdenv.mkDerivation {
name = "jupyter";
builder = with pythonPackages; with pkgs; writeText "builder.sh" ''
source $stdenv/setup
mkdir -p $out/share/jupyter/nbextensions
mkdir -p $out/share/jupyter/migrated
mkdir -p $out/share/jupyter/jupyter_notebook_config.d
ln -s ${jupyter_nbconfig} $out/share/jupyter/nbconfig
ln -s ${jupyter-contrib-nbextensions}/${python.sitePackages}/jupyter-contrib-nbextensions/nbextensions/* $out/share/jupyter/nbextensions
ln -s ${rise}/${python.sitePackages}/rise/static $out/share/jupyter/nbextensions/rise
ln -s ${vim_binding} $out/share/jupyter/nbextensions/vim_binding
ln -s ${widgetsnbextension}/share/jupyter/nbextensions/* $out/share/jupyter/nbextensions
${python.withPackages (ps: with ps; [ robotkernel ])}/bin/python -m robotkernel.install --prefix=$out
cp -R ${python.withPackages (ps: with ps; [ robotkernel ])}/etc/jupyter/jupyter_notebook_config.d/* $out/share/jupyter/jupyter_notebook_config.d
JUPYTER_CONFIG_DIR=$out/share/jupyter \
PATH=${python.withPackages (ps: with ps; [ jupyter-starters ])}/bin \
${python.withPackages (ps: with ps; [ jupyter-starters ])}/bin/jupyter serverextension enable --py jupyter_starters
JUPYTER_CONFIG_DIR=$out/share/jupyter \
PATH=${python.withPackages (ps: with ps; [ notebook jupytext ])}/bin \
${python.withPackages (ps: with ps; [ notebook jupytext ])}/bin/jupyter serverextension enable jupytext
echo "import rise" >> $out/share/jupyter/jupyter_notebook_config.py
cat > $out/share/jupyter/jupyter_nbconvert_config.py << EOF
c = get_config()
c.Exporter.preprocessors = ['jupyter_contrib_nbextensions.nbconvert_support.pre_pymarkdown.PyMarkdownPreprocessor']
EOF
'';
};
};
in with self;
pkgs.stdenv.mkDerivation rec {
name = "jupyter";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup; ln -s $env $out
'';
buildInputs = [
pkgs.nodejs
pkgs.firefox
pkgs.geckodriver
jupyter
jupyter_config_dir
] ++ (with pkgs; lib.optionals stdenv.isLinux [ bash fontconfig tini ])
++ (with pkgs; lib.optionals sikuli [ jre8 ]);
shellHook = ''
mkdir -p $(pwd)/.jupyter
chmod u+w -R $(pwd)/.jupyter
cp -R ${jupyter_config_dir}/share/jupyter/* $(pwd)/.jupyter
export JUPYTER_CONFIG_DIR=$(pwd)/.jupyter
export JUPYTER_PATH=$(pwd)/.jupyter
export JUPYTER_DATA_DIR=$(pwd)/.jupyter
export JUPYTER_RUNTIME_DIR=$(pwd)/.jupyter
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
'';
}