File tree 2 files changed +47
-4
lines changed
2 files changed +47
-4
lines changed Original file line number Diff line number Diff line change 198
198
};
199
199
```
200
200
201
- Here, the ` p ` argument corresponds to Nixpkgs checkout being used.
201
+ Here, the ` p ` argument corresponds to Nixpkgs checkout being used. Note that
202
+ this can easily be made to use packages from outside ` jupyterWith ` 's scope, by
203
+ providing a function that ignores its argument:
204
+
205
+ ``` nix
206
+ extraPackages = _ : [ pkgs.pandoc ];
207
+ ```
208
+
209
+ You may also bring all inputs from a package in scope using the
210
+ "extraInputsFrom" argument:
211
+
212
+ ``` nix
213
+ let
214
+ jupyter = import (builtins.fetchGit {
215
+ url = https://github.com/tweag/jupyterWith;
216
+ rev = "";
217
+ }) {};
218
+
219
+ jupyterEnvironment = jupyter.jupyterlabWith {
220
+ extraInputsFrom = p: [p.pythonPackages.numpy];
221
+ };
222
+ ```
202
223
203
224
## Using as an overlay
204
225
224
245
pkgs.jupyterWith;
225
246
```
226
247
248
+ ## Importing local python packages
249
+
250
+ You may use the ` extraJupyterPath ` arguments to add local
251
+ python packages in scope:
252
+
253
+ ```
254
+ let
255
+ jupyter = import (builtins.fetchGit {
256
+ url = https://github.com/tweag/jupyterWith;
257
+ rev = "";
258
+ }) {};
259
+
260
+ jupyterEnvironment = jupyter.jupyterlabWith {
261
+ extraJupyterPath = "${builtins.toPath ./.}/local_module/";
262
+ };
263
+ ```
264
+
265
+
227
266
## Contributing
228
267
229
268
### Kernels
Original file line number Diff line number Diff line change 18
18
defaultDirectory = "${ python3 . jupyterlab } /share/jupyter/lab" ;
19
19
defaultKernels = [ ( kernels . iPythonWith { } ) ] ;
20
20
defaultExtraPackages = p : [ ] ;
21
+ defaultExtraInputsFrom = p : [ ] ;
21
22
22
23
# JupyterLab with the appropriate kernel and directory setup.
23
24
jupyterlabWith = {
24
25
directory ? defaultDirectory ,
25
26
kernels ? defaultKernels ,
26
- extraPackages ? defaultExtraPackages
27
+ extraPackages ? defaultExtraPackages ,
28
+ extraInputsFrom ? defaultExtraInputsFrom ,
29
+ extraJupyterPath ? ""
27
30
} :
28
31
let
29
32
# PYTHONPATH setup for JupyterLab
39
42
python3 . jupyterlab . overridePythonAttrs ( oldAttrs : {
40
43
makeWrapperArgs = [
41
44
"--set JUPYTERLAB_DIR ${ directory } "
42
- "--set JUPYTER_PATH ${ kernelsString kernels } "
43
- "--set PYTHONPATH ${ pythonPath } "
45
+ "--set JUPYTER_PATH ${ extraJupyterPath } : ${ kernelsString kernels } "
46
+ "--set PYTHONPATH ${ extraJupyterPath } : ${ pythonPath } "
44
47
] ;
45
48
} )
46
49
) ;
47
50
48
51
# Shell with the appropriate JupyterLab, launching it at startup.
49
52
env = pkgs . mkShell {
50
53
name = "jupyterlab-shell" ;
54
+ inputsFrom = extraInputsFrom pkgs ;
51
55
buildInputs =
52
56
[ jupyterlab generateDirectory pkgs . nodejs ] ++
53
57
( map ( k : k . runtimePackages ) kernels ) ++
You can’t perform that action at this time.
0 commit comments