diff options
author | Chris Hodapp <hodapp87@gmail.com> | 2017-01-27 18:54:50 -0500 |
---|---|---|
committer | Chris Hodapp <hodapp87@gmail.com> | 2017-01-27 18:54:50 -0500 |
commit | 7638578342fa7b053095a4f89cc65cba8c70b3a2 (patch) | |
tree | 34f91b18288af4a714a32fa8cc579c3cb93a1039 /pkgs/applications/editors/rstudio | |
parent | d75035fbf818981327605a099b4ddff62c9e74ca (diff) |
RStudio: Optionally allow packages from custom R environment
https://nixos.org/nixpkgs/manual/#r-packages contains a method for
setting up an R environment with a specific set of libraries, and it
creates an R wrapper which points R to those libraries.
The package RStudio relies on the standard R package, which then
cannot access any of the libraries specified in a custom R
environment. While one may easily use pkgs.rstudio.override to change
rstudio's R dependency to the custom R environment, this accomplishes
nothing because while RStudio runs the correct R wrapper it clears out
the environment variable R_LIBS_SITE - and so it is still unable to
use any of those packages.
In order to work around this problem, these changes allow the user to
optionally modify rstudio's wrapper to set environment variable
R_PROFILE_USER to an R script which sets R's .libPaths(..) to point to
the same libraries; that script is generated from R_LIBS_SITE in the R
wrapper.
By default, this change has no effect. If R is overridden to
something else, and if useRPackages is changed from its default of
false, then the change described above is made; for instance:
{
packageOverrides = pkgs: let self = pkgs.pkgs; in
rec {
rEnv = pkgs.rWrapper.override {
packages = with self.rPackages; [
dplyr ggplot2 e1071 rpart reshape
];
};
rstudioEnv = pkgs.rstudio.override { R = rEnv; useRPackages = true; };
};
}
Diffstat (limited to 'pkgs/applications/editors/rstudio')
-rw-r--r-- | pkgs/applications/editors/rstudio/default.nix | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/pkgs/applications/editors/rstudio/default.nix b/pkgs/applications/editors/rstudio/default.nix index 82bcc485da3c..5fef166e663f 100644 --- a/pkgs/applications/editors/rstudio/default.nix +++ b/pkgs/applications/editors/rstudio/default.nix @@ -1,4 +1,14 @@ -{ stdenv, fetchurl, makeDesktopItem, cmake, boost155, zlib, openssl, R, qt4, libuuid, hunspellDicts, unzip, ant, jdk, gnumake, makeWrapper }: +{ stdenv, fetchurl, makeDesktopItem, cmake, boost155, zlib, openssl, +R, qt4, libuuid, hunspellDicts, unzip, ant, jdk, gnumake, makeWrapper, +# If you have set up an R wrapper with other packages by following +# something like https://nixos.org/nixpkgs/manual/#r-packages, RStudio +# by default not be able to access any of those R packages. In order +# to do this, override the argument "R" here with your respective R +# wrapper, and set "useRPackages" to true. This will add the +# environment variable R_PROFILE_USER to the RStudio wrapper, pointing +# to an R script which will allow R to use these packages. +useRPackages ? false +}: let version = "0.98.110"; @@ -72,8 +82,14 @@ stdenv.mkDerivation rec { mimeType = "text/x-r-source;text/x-r;text/x-R;text/x-r-doc;text/x-r-sweave;text/x-r-markdown;text/x-r-html;text/x-r-presentation;application/x-r-data;application/x-r-project;text/x-r-history;text/x-r-profile;text/x-tex;text/x-markdown;text/html;text/css;text/javascript;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;"; }; - postInstall = '' - wrapProgram $out/bin/rstudio --suffix PATH : ${gnumake}/bin + postInstall = let rProfile = + # RStudio seems to bypass the environment variables that the R + # wrapper already applies, and so this sets R_PROFILE_USER to + # again make those R packages accessible: + if useRPackages + then "--set R_PROFILE_USER ${R}/${R.passthru.fixLibsR}" else ""; + in '' + wrapProgram $out/bin/rstudio --suffix PATH : ${gnumake}/bin ${rProfile} mkdir $out/share cp -r ${desktopItem}/share/applications $out/share mkdir $out/share/icons |