2014-05-04 23:12:34 +04:00
|
|
|
{ stdenv, R, makeWrapper, recommendedPackages, packages }:
|
2014-05-04 17:20:51 +04:00
|
|
|
|
2017-01-28 02:54:50 +03:00
|
|
|
stdenv.mkDerivation rec {
|
2014-05-04 17:20:51 +04:00
|
|
|
name = R.name + "-wrapper";
|
|
|
|
|
2014-05-04 23:12:34 +04:00
|
|
|
buildInputs = [makeWrapper R] ++ recommendedPackages ++ packages;
|
2014-05-04 17:20:51 +04:00
|
|
|
|
|
|
|
unpackPhase = ":";
|
|
|
|
|
2017-01-28 02:54:50 +03:00
|
|
|
# This filename is used in 'installPhase', but needs to be
|
|
|
|
# referenced elsewhere. This will be relative to this package's
|
|
|
|
# path.
|
|
|
|
passthru = {
|
|
|
|
fixLibsR = "fix_libs.R";
|
|
|
|
};
|
|
|
|
|
2014-05-04 17:20:51 +04:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cd ${R}/bin
|
|
|
|
for exe in *; do
|
|
|
|
makeWrapper ${R}/bin/$exe $out/bin/$exe \
|
|
|
|
--prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE"
|
|
|
|
done
|
2017-01-28 02:54:50 +03:00
|
|
|
# RStudio (and perhaps other packages) overrides the R_LIBS_SITE
|
|
|
|
# which the wrapper above applies, and as a result packages
|
|
|
|
# installed in the wrapper (as in the method described in
|
|
|
|
# https://nixos.org/nixpkgs/manual/#r-packages) aren't visible.
|
|
|
|
# The below turns R_LIBS_SITE into some R startup code which can
|
|
|
|
# correct this.
|
|
|
|
echo "# Autogenerated by wrapper.nix from R_LIBS_SITE" > $out/${passthru.fixLibsR}
|
|
|
|
echo -n ".libPaths(c(.libPaths(), \"" >> $out/${passthru.fixLibsR}
|
|
|
|
echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/${passthru.fixLibsR}
|
|
|
|
echo -n "\"))" >> $out/${passthru.fixLibsR}
|
|
|
|
echo >> $out/${passthru.fixLibsR}
|
2014-05-04 17:20:51 +04:00
|
|
|
'';
|
2016-08-02 19:06:29 +03:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = stdenv.lib.platforms.unix;
|
|
|
|
};
|
2014-05-04 17:20:51 +04:00
|
|
|
}
|