Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created December 28, 2019 14:57
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/2760ce599037c1bc9013f21929f43aeb to your computer and use it in GitHub Desktop.
Save idontgetoutmuch/2760ce599037c1bc9013f21929f43aeb to your computer and use it in GitHub Desktop.
let
pkgs = import <nixpkgs> {};
in
let
my-R-packages = with pkgs.rPackages; [ rstan zoo ggplot2 dplyr coda ];
R-with-my-packages = pkgs.rWrapper.override{ packages = with pkgs.rPackages; my-R-packages ++ [ JuniperKernel ]; };
jupyter-R-kernel = pkgs.stdenv.mkDerivation {
name = "jupyter-R-kernel";
buildInputs = [ pkgs.python37Packages.notebook R-with-my-packages pkgs.which ];
unpackPhase = ":";
installPhase = ''
export HOME=$TMP
echo $JUPYTER_PATH
${R-with-my-packages}/bin/R --slave -e "JuniperKernel::listKernels()"
${R-with-my-packages}/bin/R --slave -e "JuniperKernel::installJuniper(prefix='$out')"
'';
};
in
pkgs.mkShell rec {
name = "jupyter-with-R-kernel";
buildInputs = [ pkgs.libintl jupyter-R-kernel pkgs.python37Packages.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')"
'';
}
@idontgetoutmuch
Copy link
Author

/nix/store/1y8hjma2nvvjs1gykzqk2kcdhf5s76x8-stdenv-darwin/setup: line 1305: 19846 Abort trap: 6           HOME=$(mktemp -d) pytest ipykernel -k "not (test_sys_path or test_sys_path_profile_dir or test_complete)"
builder for '/nix/store/4pkb2val8chj09h2ykawk0d46b7ciflj-python3.7-ipykernel-5.1.2.drv' failed with exit code 134
cannot build derivation '/nix/store/sachnfnhhy2n2722cvqdcpxq265234al-python3.7-jupyter-1.0.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/csh3sa2b31p2jh22wj25rkh8g6clfysa-jupyter-R-kernel.drv', '/nix/store/sachnfnhhy2n2722cvqdcpxq265234al-python3.7-jupyter-1.0.0.drv' failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment