mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 18:23:09 +00:00
29969a5ec7
This attempts to fix the issue described at https://github.com/NixOS/nixpkgs/pull/22219#issuecomment-291801133. Any change to the custom packages passed to RStudio causes this to completely rebuild RStudio, which is completely unnecessary and also a bit of a hindrance as it's a fairly slow build. This rolls back most of that old PR, and instead implements something more like rWrapper. Existing configurations with the old useRPackages will break.
34 lines
1.3 KiB
Nix
34 lines
1.3 KiB
Nix
{ stdenv, R, rstudio, makeWrapper, recommendedPackages, packages }:
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = rstudio.name + "-wrapper";
|
|
|
|
buildInputs = [makeWrapper R rstudio] ++ recommendedPackages ++ packages;
|
|
|
|
unpackPhase = ":";
|
|
|
|
# rWrapper points R to a specific set of packages by using a wrapper
|
|
# (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets
|
|
# R_LIBS_SITE. Ordinarily, it would be possible to make RStudio use
|
|
# this same set of packages by simply overriding its version of R
|
|
# with the wrapped one, however, RStudio internally overrides
|
|
# R_LIBS_SITE. The below works around this by turning R_LIBS_SITE
|
|
# into an R file (fixLibsR) which achieves the same effect, then
|
|
# uses R_PROFILE_USER to load this code at startup in RStudio.
|
|
fixLibsR = "fix_libs.R";
|
|
installPhase = ''
|
|
mkdir $out
|
|
echo "# Autogenerated by wrapper-rstudio.nix from R_LIBS_SITE" > $out/${fixLibsR}
|
|
echo -n ".libPaths(c(.libPaths(), \"" >> $out/${fixLibsR}
|
|
echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/${fixLibsR}
|
|
echo -n "\"))" >> $out/${fixLibsR}
|
|
echo >> $out/${fixLibsR}
|
|
makeWrapper ${rstudio}/bin/rstudio $out/bin/rstudio --set R_PROFILE_USER $out/${fixLibsR}
|
|
'';
|
|
|
|
meta = {
|
|
platforms = stdenv.lib.platforms.unix;
|
|
};
|
|
}
|