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