Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created September 1, 2019 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idontgetoutmuch/ac918fbf0b667de89efb275953ce011e to your computer and use it in GitHub Desktop.
Save idontgetoutmuch/ac918fbf0b667de89efb275953ce011e to your computer and use it in GitHub Desktop.
R kernel jupyter 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 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