Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created December 29, 2019 10:30
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/12cc6599563d9b3299c212d9b7348bdd to your computer and use it in GitHub Desktop.
Save idontgetoutmuch/12cc6599563d9b3299c212d9b7348bdd to your computer and use it in GitHub Desktop.
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')"
'';
}
@idontgetoutmuch
Copy link
Author

bash-3.2$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz py-only.nix
these derivations will be built:
  /nix/store/da72h8j1afm8wi1430fvl3hm02x0sxyr-r-JupiterKernel.drv
  /nix/store/lc29rgz92bhcrsysaz1fb7wvkhqzf8bp-R-3.6.1-wrapper.drv
  /nix/store/6c7vajxk7irrk7jlijd8znaazi8kga2w-jupyter-R-kernel.drv
building '/nix/store/da72h8j1afm8wi1430fvl3hm02x0sxyr-r-JupiterKernel.drv'...
unpacking sources
unpacking source archive /nix/store/3dll3y6s60x666n3xa918jgxsf1gar1m-JuniperKernel_1.2.3.0.tar.gz
source root is JuniperKernel
setting SOURCE_DATE_EPOCH to timestamp 1517851556 of file JuniperKernel/MD5
patching sources
configuring
patching script interpreter paths in configure
configure: interpreter directive changed from "/bin/bash" to "/nix/store/manwblxv4n70fwji369liqc7g9jbl0vr-bash-4.4-p23/bin/bash"
building
installing
* installing *source* package 'JuniperKernel' ...
file 'configure' has the wrong MD5 checksum
** using staged installation

************** Results of JuniperKernel package configure **************

>> RSCRIPT = /nix/store/cl0l24psv2ci0hxc8brh6yw3qkpsyjgk-R-3.6.1/lib/R/bin/Rscript
>> PBD_ZMQ = /nix/store/za581brg9ixh2nvjxcc2wx69y0i9k845-r-pbdZMQ-0.3-3/library/pbdZMQ
>> ZMQ_CPPFLAGS = -I"/nix/store/za581brg9ixh2nvjxcc2wx69y0i9k845-r-pbdZMQ-0.3-3/library/pbdZMQ/zmq/include"
>> ZMQ_LDFLAGS = -L"/nix/store/za581brg9ixh2nvjxcc2wx69y0i9k845-r-pbdZMQ-0.3-3/library/pbdZMQ/libs" -lzmq.5

************************************************************************

** libs
/nix/store/cwrk2vqzxjrx0rbcbiwwjzchqcryy403-clang-wrapper-7.1.0/bin/c++ -std=gnu++11 -I"/nix/store/cl0l24psv2ci0hxc8brh6yw3qkpsyjgk-R-3.6.1/lib/R/include" -DNDEBUG -I../inst/include/ -I. -I"/nix/store/za581brg9ixh2nvjxcc2wx69y0i9k845-r-pbdZMQ-0.3-3/library/pbdZMQ/zmq/include" -I"/nix/store/75kxvz4799m43l4vjzn4cgl33kijmmp5-r-Rcpp-1.0.2/library/Rcpp/include" -I"/nix/store/knlvfdk79lhl3mymwq08khxrngvrhc3s-r-gdtools-0.1.9/library/gdtools/include" -isystem /nix/store/pmsxk1p264ia2176fipaplnrvpgmic87-libc++-7.1.0/include/c++/v1  -fPIC  -g -O2  -c RcppExports.cpp -o RcppExports.o
/nix/store/cwrk2vqzxjrx0rbcbiwwjzchqcryy403-clang-wrapper-7.1.0/bin/c++ -std=gnu++11 -I"/nix/store/cl0l24psv2ci0hxc8brh6yw3qkpsyjgk-R-3.6.1/lib/R/include" -DNDEBUG -I../inst/include/ -I. -I"/nix/store/za581brg9ixh2nvjxcc2wx69y0i9k845-r-pbdZMQ-0.3-3/library/pbdZMQ/zmq/include" -I"/nix/store/75kxvz4799m43l4vjzn4cgl33kijmmp5-r-Rcpp-1.0.2/library/Rcpp/include" -I"/nix/store/knlvfdk79lhl3mymwq08khxrngvrhc3s-r-gdtools-0.1.9/library/gdtools/include" -isystem /nix/store/pmsxk1p264ia2176fipaplnrvpgmic87-libc++-7.1.0/include/c++/v1  -fPIC  -g -O2  -c juniper.cpp -o juniper.o
/nix/store/cwrk2vqzxjrx0rbcbiwwjzchqcryy403-clang-wrapper-7.1.0/bin/c++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/nix/store/cl0l24psv2ci0hxc8brh6yw3qkpsyjgk-R-3.6.1/lib/R/lib -L/nix/store/pmsxk1p264ia2176fipaplnrvpgmic87-libc++-7.1.0/lib -o JuniperKernel.so RcppExports.o juniper.o -L/nix/store/za581brg9ixh2nvjxcc2wx69y0i9k845-r-pbdZMQ-0.3-3/library/pbdZMQ/libs -lzmq.5 -L/nix/store/cl0l24psv2ci0hxc8brh6yw3qkpsyjgk-R-3.6.1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
installing via 'install.libs.R' to /nix/store/yggpnwrsawhx5qajafwjydzj4hih3cjv-r-JupiterKernel/library/00LOCK-JuniperKernel/00new/JuniperKernel
sh: which: command not found
Error in system("which install_name_tool", intern = TRUE) :
  error in running command
* removing '/nix/store/yggpnwrsawhx5qajafwjydzj4hih3cjv-r-JupiterKernel/library/JuniperKernel'
builder for '/nix/store/da72h8j1afm8wi1430fvl3hm02x0sxyr-r-JupiterKernel.drv' failed with exit code 1
cannot build derivation '/nix/store/lc29rgz92bhcrsysaz1fb7wvkhqzf8bp-R-3.6.1-wrapper.drv': 1 dependencies couldn't be built
error: build of '/nix/store/6c7vajxk7irrk7jlijd8znaazi8kga2w-jupyter-R-kernel.drv', '/nix/store/lc29rgz92bhcrsysaz1fb7wvkhqzf8bp-R-3.6.1-wrapper.drv' failed

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