Merge pull request #51581 from joachifm/rWrapper-local-runCommand

Implement R wrappers as local-only runCommand
This commit is contained in:
Joachim F 2018-12-07 09:17:44 +00:00 committed by GitHub
commit f0dbbdf970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 41 deletions

View File

@ -1,15 +1,15 @@
{ stdenv, R, rstudio, makeWrapper, recommendedPackages, packages, qtbase }: { lib, runCommand, R, rstudio, makeWrapper, recommendedPackages, packages, qtbase }:
let let
qtVersion = with stdenv.lib.versions; "${major qtbase.version}.${minor qtbase.version}"; qtVersion = with lib.versions; "${major qtbase.version}.${minor qtbase.version}";
in in
stdenv.mkDerivation rec { runCommand (rstudio.name + "-wrapper") {
preferLocalBuild = true;
allowSubstitutes = false;
name = rstudio.name + "-wrapper"; nativeBuildInputs = [makeWrapper];
buildInputs = [makeWrapper R rstudio] ++ recommendedPackages ++ packages; buildInputs = [R rstudio] ++ recommendedPackages ++ packages;
unpackPhase = ":";
# rWrapper points R to a specific set of packages by using a wrapper # rWrapper points R to a specific set of packages by using a wrapper
# (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets # (as in https://nixos.org/nixpkgs/manual/#r-packages) which sets
@ -20,18 +20,14 @@ stdenv.mkDerivation rec {
# into an R file (fixLibsR) which achieves the same effect, then # into an R file (fixLibsR) which achieves the same effect, then
# uses R_PROFILE_USER to load this code at startup in RStudio. # uses R_PROFILE_USER to load this code at startup in RStudio.
fixLibsR = "fix_libs.R"; 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} \
--prefix QT_PLUGIN_PATH : ${qtbase}/lib/qt-${qtVersion}/plugins
'';
meta = {
platforms = stdenv.lib.platforms.unix;
};
} }
''
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 \
--prefix QT_PLUGIN_PATH : ${qtbase}/lib/qt-${qtVersion}/plugins
''

View File

@ -1,25 +1,21 @@
{ stdenv, R, makeWrapper, recommendedPackages, packages }: { runCommand, R, makeWrapper, recommendedPackages, packages }:
stdenv.mkDerivation { runCommand (R.name + "-wrapper") {
name = R.name + "-wrapper"; preferLocalBuild = true;
allowSubstitutes = false;
buildInputs = [makeWrapper R] ++ recommendedPackages ++ packages; buildInputs = [R] ++ recommendedPackages ++ packages;
nativeBuildInputs = [makeWrapper];
# Make the list of recommended R packages accessible to other packages such as rpy2 # Make the list of recommended R packages accessible to other packages such as rpy2
passthru.recommendedPackages = recommendedPackages; passthru = { inherit recommendedPackages; };
}
unpackPhase = ":"; ''
mkdir -p $out/bin
installPhase = '' cd ${R}/bin
mkdir -p $out/bin for exe in *; do
cd ${R}/bin
for exe in *; do
makeWrapper ${R}/bin/$exe $out/bin/$exe \ makeWrapper ${R}/bin/$exe $out/bin/$exe \
--prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE" --prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE"
done done
''; ''
meta = {
platforms = stdenv.lib.platforms.unix;
};
}