Skip to content

Commit 882d056

Browse files
authored
Merge pull request tweag#33 from TBILLC/irkernel
Add IRkernel
2 parents 2074d36 + 8dd3b0d commit 882d056

File tree

10 files changed

+315
-1
lines changed

10 files changed

+315
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ These kernels are currently included by default:
1818
- [CKernel](https://github.com/brendan-rius/jupyter-c-kernel)
1919
- [IRuby](https://github.com/SciRuby/iruby)
2020
- [Juniper RKernel](https://github.com/JuniperKernel/JuniperKernel) (limited jupyterlab support)
21+
- [IRkernel](https://github.com/IRkernel/IRkernel)
2122
- [Ansible Kernel](https://github.com/ansible/ansible-jupyter-kernel)
2223
- [Xeus-Cling CPP](https://github.com/QuantStack/xeus-cling) (experimental, not yet configurable with packages, long build time)
2324
- [IJavascript](https://github.com/n-riesco/ijavascript) (not yet configurable with packages)
File renamed without changes.

example/R/IRkernel/ggplot/shell.nix

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let
2+
jupyterLibPath = ../../../..;
3+
jupyter = import jupyterLibPath {};
4+
5+
jupyterlabWithKernels = jupyter.jupyterlabWith {
6+
kernels = [
7+
(jupyter.kernels.iRWith {
8+
name = "ggplot";
9+
packages = p: with p; [ ggplot2 ];
10+
})
11+
];
12+
};
13+
in
14+
jupyterlabWithKernels.env

example/R/Juniper/ggplot/iris.ipynb

+125
Large diffs are not rendered by default.

example/R/ggplot/shell.nix example/R/Juniper/ggplot/shell.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let
2-
jupyterLibPath = ../../..;
2+
jupyterLibPath = ../../../..;
33
jupyter = import jupyterLibPath {};
44

55
jupyterlabWithKernels = jupyter.jupyterlabWith {

kernels/default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
iHaskellWith = callPackage ./ihaskell;
55
juniperWith = callPackage ./juniper;
6+
iRWith = callPackage ./irkernel;
67
iPythonWith = callPackage ./ipython;
78
iRubyWith = callPackage ./iruby;
89
cKernelWith = callPackage ./ckernel;

kernels/irkernel/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# JupyterWith IRkernel
2+
3+
The IRkernel can be used as follows:
4+
5+
```nix
6+
{
7+
irkernel = iRWith {
8+
# Identifier that will appear on the Jupyter interface.
9+
name = "nixpkgs";
10+
# Libraries to be available to the kernel.
11+
packages = p: with p; [ p.ggplot2 ];
12+
# Optional definition of `rPackages` to be used.
13+
# Useful for overlaying packages.
14+
rPackages = pkgs.rPackages;
15+
};
16+
}
17+
```

kernels/irkernel/default.nix

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{ stdenv
2+
, rWrapper
3+
, rPackages
4+
, name ? "nixpkgs"
5+
, packages ? (_:[])
6+
}:
7+
8+
let
9+
kernelEnv = rWrapper.override{ packages = (packages rPackages) ++ [ rPackages.IRkernel ]; };
10+
11+
kernelFile = {
12+
argv = [
13+
"${kernelEnv}/bin/R"
14+
"--slave"
15+
"-e"
16+
"IRkernel::main()"
17+
"--args"
18+
"{connection_file}"
19+
];
20+
display_name = "R - " + name;
21+
language = "R";
22+
logo64 = "logo-64x64.png";
23+
};
24+
25+
IRkernel = stdenv.mkDerivation {
26+
name = "IRkernel";
27+
phases = "installPhase";
28+
src = ./ir.svg;
29+
buildInputs = [];
30+
installPhase = ''
31+
mkdir -p $out/kernels/ir_${name}
32+
cp $src $out/kernels/ir_${name}/logo-64x64.svg
33+
echo '${builtins.toJSON kernelFile}' > $out/kernels/ir_${name}/kernel.json
34+
'';
35+
};
36+
in
37+
{
38+
spec = IRkernel;
39+
runtimePackages = [];
40+
}

kernels/irkernel/ir.svg

+112
Loading

tests/default.nix

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ let
3636
name = "test";
3737
})
3838

39+
( iRWith {
40+
name = "test";
41+
})
42+
3943
#( xeusCling {
4044
# name = "test";
4145
#})

0 commit comments

Comments
 (0)