Created
September 1, 2019 11:27
-
-
Save idontgetoutmuch/ac918fbf0b667de89efb275953ce011e to your computer and use it in GitHub Desktop.
R kernel jupyter nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 jupyter ]; | |
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')" | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment