Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created September 6, 2019 17:59
Show Gist options
  • Save idontgetoutmuch/0b836790096685c0ec68c224cede869c to your computer and use it in GitHub Desktop.
Save idontgetoutmuch/0b836790096685c0ec68c224cede869c to your computer and use it in GitHub Desktop.
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
echo $JUPYTER_PATH
${R-with-my-packages}/bin/R --slave -e "JuniperKernel::installJuniper(prefix='$out'); JuniperKernel::listKernels()"
'';
};
in
mkShell rec {
name = "jupyter-with-R-kernel";
buildInputs = [ jupyter-R-kernel pythonPackages.jupyter ];
shellHook = ''
export HOME=$TMP
export JUPYTER_PATH=${jupyter-R-kernel}/share/jupyter
echo ${R-with-my-packages}/bin/R
# 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