From d2b467a2de7212b078fb970c70675c55da5038e3 Mon Sep 17 00:00:00 2001 From: Joachim Fasting Date: Wed, 5 Dec 2018 18:40:06 +0100 Subject: [PATCH 1/2] rWrapper: use runCommand, local build only This seems more appropriate for a wrapper generator. --- pkgs/development/r-modules/wrapper.nix | 36 ++++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/pkgs/development/r-modules/wrapper.nix b/pkgs/development/r-modules/wrapper.nix index d77c24e913d3..76e819501a57 100644 --- a/pkgs/development/r-modules/wrapper.nix +++ b/pkgs/development/r-modules/wrapper.nix @@ -1,25 +1,21 @@ -{ stdenv, R, makeWrapper, recommendedPackages, packages }: +{ runCommand, R, makeWrapper, recommendedPackages, packages }: -stdenv.mkDerivation { - name = R.name + "-wrapper"; +runCommand (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 - passthru.recommendedPackages = recommendedPackages; - - unpackPhase = ":"; - - installPhase = '' - mkdir -p $out/bin - cd ${R}/bin - for exe in *; do - makeWrapper ${R}/bin/$exe $out/bin/$exe \ - --prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE" - done - ''; - - meta = { - platforms = stdenv.lib.platforms.unix; - }; + passthru = { inherit recommendedPackages; }; } +'' +mkdir -p $out/bin +cd ${R}/bin +for exe in *; do + makeWrapper ${R}/bin/$exe $out/bin/$exe \ + --prefix "R_LIBS_SITE" ":" "$R_LIBS_SITE" +done +'' From 21d83e5b1164d1ddac5989168b1501354420b560 Mon Sep 17 00:00:00 2001 From: Joachim Fasting Date: Wed, 5 Dec 2018 19:04:04 +0100 Subject: [PATCH 2/2] rstudioWrapper: use runCommand, local build only This seems more appropriate for a wrapper generator. --- .../development/r-modules/wrapper-rstudio.nix | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/pkgs/development/r-modules/wrapper-rstudio.nix b/pkgs/development/r-modules/wrapper-rstudio.nix index 8ad3a103c93a..5cbedf403d21 100644 --- a/pkgs/development/r-modules/wrapper-rstudio.nix +++ b/pkgs/development/r-modules/wrapper-rstudio.nix @@ -1,15 +1,15 @@ -{ stdenv, R, rstudio, makeWrapper, recommendedPackages, packages, qtbase }: +{ lib, runCommand, R, rstudio, makeWrapper, recommendedPackages, packages, qtbase }: let - qtVersion = with stdenv.lib.versions; "${major qtbase.version}.${minor qtbase.version}"; + qtVersion = with lib.versions; "${major qtbase.version}.${minor qtbase.version}"; in -stdenv.mkDerivation rec { +runCommand (rstudio.name + "-wrapper") { + preferLocalBuild = true; + allowSubstitutes = false; - name = rstudio.name + "-wrapper"; + nativeBuildInputs = [makeWrapper]; - buildInputs = [makeWrapper R rstudio] ++ recommendedPackages ++ packages; - - unpackPhase = ":"; + buildInputs = [R rstudio] ++ recommendedPackages ++ packages; # rWrapper points R to a specific set of packages by using a wrapper # (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 # 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} \ - --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 +''