11 runCommand (rstudio.name + "-wrapper")
13 preferLocalBuild = true;
14 allowSubstitutes = false;
16 nativeBuildInputs = [ (if rstudio.server then makeWrapper else wrapQtAppsHook) ];
17 dontWrapQtApps = true;
19 buildInputs = [ R rstudio ] ++ recommendedPackages ++ packages;
21 # rWrapper points R to a specific set of packages by using a wrapper
22 # (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets
23 # R_LIBS_SITE. Ordinarily, it would be possible to make RStudio use
24 # this same set of packages by simply overriding its version of R
25 # with the wrapped one, however, RStudio internally overrides
26 # R_LIBS_SITE. The below works around this by turning R_LIBS_SITE
27 # into an R file (fixLibsR) which achieves the same effect, then
28 # uses R_PROFILE_USER to load this code at startup in RStudio.
29 fixLibsR = "fix_libs.R";
34 ln -s ${rstudio}/share $out
35 echo "# Autogenerated by wrapper-rstudio.nix from R_LIBS_SITE" > $out/$fixLibsR
36 echo -n ".libPaths(c(.libPaths(), \"" >> $out/$fixLibsR
37 echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/$fixLibsR
38 echo -n "\"))" >> $out/$fixLibsR
39 echo >> $out/$fixLibsR
42 rstudio.server then ''
43 makeWrapper ${rstudio}/bin/rsession $out/bin/rsession \
44 --set R_PROFILE_USER $out/$fixLibsR --set FONTCONFIG_FILE ${fontconfig.out}/etc/fonts/fonts.conf
46 makeWrapper ${rstudio}/bin/rserver $out/bin/rserver \
47 --add-flags --rsession-path=$out/bin/rsession
51 makeQtWrapper ${rstudio}/bin/rstudio $out/bin/rstudio \
52 --set R_PROFILE_USER $out/$fixLibsR