nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 69 lines 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 runCommand, 5 R, 6 rstudio, 7 makeWrapper, 8 recommendedPackages, 9 packages, 10 fontconfig, 11}: 12 13runCommand (rstudio.name + "-wrapper") 14 { 15 preferLocalBuild = true; 16 allowSubstitutes = false; 17 18 nativeBuildInputs = [ makeWrapper ]; 19 dontWrapQtApps = true; 20 21 buildInputs = [ 22 R 23 rstudio 24 ] 25 ++ recommendedPackages 26 ++ packages; 27 28 # rWrapper points R to a specific set of packages by using a wrapper 29 # (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets 30 # R_LIBS_SITE. Ordinarily, it would be possible to make RStudio use 31 # this same set of packages by simply overriding its version of R 32 # with the wrapped one, however, RStudio internally overrides 33 # R_LIBS_SITE. The below works around this by turning R_LIBS_SITE 34 # into an R file (fixLibsR) which achieves the same effect, then 35 # uses R_PROFILE to load this code at startup in RStudio. 36 fixLibsR = "fix_libs.R"; 37 } 38 ( 39 '' 40 mkdir -p $out 41 echo "# Autogenerated by wrapper-rstudio.nix from R_LIBS_SITE" > $out/$fixLibsR 42 echo -n ".libPaths(c(.libPaths(), \"" >> $out/$fixLibsR 43 echo -n $R_LIBS_SITE | sed -e 's/:/", "/g' >> $out/$fixLibsR 44 echo -n "\"))" >> $out/$fixLibsR 45 echo >> $out/$fixLibsR 46 '' 47 + ( 48 if rstudio.server then 49 '' 50 makeWrapper ${rstudio}/bin/rsession $out/bin/rsession \ 51 --set R_PROFILE $out/$fixLibsR --set FONTCONFIG_FILE ${fontconfig.out}/etc/fonts/fonts.conf 52 53 makeWrapper ${rstudio}/bin/rserver $out/bin/rserver \ 54 --add-flags --rsession-path=$out/bin/rsession 55 '' 56 else 57 '' 58 ${lib.optionalString stdenv.hostPlatform.isLinux '' 59 # symlink files from unwrapped rstudio so that the desktop file and the icons 60 # are also installed when using the wrapped version 61 # TODO: figure out how to handle darwin .app structures 62 ln -s ${rstudio}/share $out 63 ''} 64 65 makeWrapper ${rstudio}/bin/rstudio $out/bin/rstudio \ 66 --set R_PROFILE $out/$fixLibsR 67 '' 68 ) 69 )