Created
December 29, 2019 10:30
-
-
Save idontgetoutmuch/12cc6599563d9b3299c212d9b7348bdd to your computer and use it in GitHub Desktop.
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
let | |
pkgs = import <nixpkgs> {}; | |
in | |
let | |
fontsConf = pkgs.makeFontsConf { fontDirectories = [ ]; }; | |
my-R-packages = with pkgs.rPackages; [ rstan zoo ggplot2 dplyr coda ]; | |
buildRPackage = | |
pkgs.callPackage "${pkgs.path}/pkgs/development/r-modules/generic-builder.nix" | |
{ Cocoa = null; Foundation = null; }; | |
JuniperKernel_1_2_3_0 = buildRPackage { | |
name = "JupiterKernel"; | |
src = pkgs.fetchurl { | |
url = https://cran.r-project.org/src/contrib/Archive/JuniperKernel/JuniperKernel_1.2.3.0.tar.gz; | |
sha256 = "17r4ssjjayvnp9fp9jalklp3p8dadyx5hvi9z3bh3sw4b7kx4lyd"; | |
}; | |
preConfigure = '' | |
patchShebangs configure | |
''; | |
requireX = false; | |
propagatedBuildInputs = with pkgs.rPackages; [ data_table gdtools jsonlite pbdZMQ Rcpp repr ]; | |
nativeBuildInputs = with pkgs.rPackages; [ data_table gdtools jsonlite pbdZMQ Rcpp repr ]; | |
}; | |
R-with-my-packages = pkgs.rWrapper.override{ packages = with pkgs.rPackages; my-R-packages ++ [ JuniperKernel_1_2_3_0 ]; }; | |
jupyter-R-kernel = pkgs.stdenv.mkDerivation { | |
name = "jupyter-R-kernel"; | |
buildInputs = [ pkgs.python36Packages.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.python36Packages.jupyter pkgs.which ]; | |
shellHook = '' | |
export FONTCONFIG_FILE=${fontsConf} | |
# Fontconfig error: Cannot load default config file | |
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')" | |
''; | |
} |
Author
idontgetoutmuch
commented
Dec 29, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment