forked from robots-from-jupyter/robotkernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
143 lines (126 loc) · 4.3 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
{ pkgs ? import (builtins.fetchTarball {
# branches nixos-19.03
url = "https://github.com/NixOS/nixpkgs-channels/archive/96151a48dd6662fb3f84bd16bbfe8a34f59d717a.tar.gz";
sha256 = "06cqc37yj23g3jbwvlf9704bl5dg8vrzqvs5y2q18ayg9sw61i6z";
}) {}
, sikuli ? false
, vim ? false
}:
let self = rec {
# python packages
pythonPackages = (import ./setup.nix {
inherit pkgs;
pythonPackages = pkgs.python3Packages;
}).pythonPackages;
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;
}).build;
# 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
iplantuml
ipywidgets
jupyter-contrib-nbextensions
jupyter-nbextensions-configurator
jupyterlab
nbimporter
opencv3
RESTinstance
rise
robotframework
robotframework-appiumlibrary
robotframework-faker
robotframework-seleniumlibrary
robotframework-seleniumscreenshots
robotkernel
tkinter
widgetsnbextension
] ++ pkgs.stdenv.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;
"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
ln -s ${jupyter_nbconfig} $out/share/jupyter/nbconfig
ln -s ${jupyter-contrib-nbextensions}/${pythonPackages.python.sitePackages}/jupyter-contrib-nbextensions/nbextensions/* $out/share/jupyter/nbextensions
ln -s ${rise}/${pythonPackages.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
${pythonPackages.python.withPackages (ps: with ps; [ robotkernel ])}/bin/python -m robotkernel.install --prefix=$out
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.firefox
pkgs.geckodriver
jupyter
jupyter_config_dir
] ++ (with pkgs; stdenv.lib.optionals stdenv.isLinux [ bash fontconfig tini ])
++ (with pkgs; stdenv.lib.optionals sikuli [ jre8 ]);
shellHook = ''
mkdir -p $(pwd)/.jupyter
export JUPYTER_CONFIG_DIR=${jupyter_config_dir}/share/jupyter
export JUPYTER_PATH=${jupyter_config_dir}/share/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
'';
}