R: Difference between revisions
imported>Krey No edit summary |
imported>Krey No edit summary |
||
Line 21: | Line 21: | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
RStudio-with-my-packages = rstudioWrapper.override{ packages = with rPackages; [ ggplot2 dplyr xts ]; }; | RStudio-with-my-packages = rstudioWrapper.override{ packages = with rPackages; [ ggplot2 dplyr xts ]; }; | ||
</syntaxhighlight> | |||
=== Jupyter Notebook === | |||
There is currently no package in nixpkgs to set up Jupyter Notebook with additional kernels. (Keep an eye [https://github.com/NixOS/nixpkgs/pull/33673 this pull request] though). | |||
For now, you can save the following into a file and run it with nix-shell: | |||
<syntaxhighlight lang="nix> | |||
with import <nixpkgs> {}; | |||
let | |||
my-R-packages = with rPackages; [ ggplot2 dplyr xts ]; | |||
R-with-my-packages = rWrapper.override{ packages = with rPackages; my-R-packages ++ [ JuniperKernel ]; }; | |||
jupyter-R-kernel = stdenv.mkDerivation { | |||
name = "jupyter-R-kernel"; | |||
buildInputs = [ pythonPackages.notebook R-with-my-packages ]; | |||
unpackPhase = ":"; | |||
installPhase = '' | |||
export HOME=$TMP | |||
${R-with-my-packages}/bin/R --slave -e "JuniperKernel::installJuniper(prefix='$out')" | |||
''; | |||
}; | |||
in | |||
mkShell rec { | |||
name = "jupyter-with-R-kernel"; | |||
buildInputs = [ jupyter-R-kernel ]; | |||
shellHook = '' | |||
export JUPYTER_PATH=${jupyter-R-kernel}/share/jupyter | |||
# see https://github.com/NixOS/nixpkgs/issues/38733 | |||
${R-with-my-packages}/bin/R --slave -e "system2('jupyter', 'notebook')" | |||
''; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> |