1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/development/r-modules
Chris Hodapp 29969a5ec7 rstudio: Fix recompilation issue with custom package set
This attempts to fix the issue described at
https://github.com/NixOS/nixpkgs/pull/22219#issuecomment-291801133.
Any change to the custom packages passed to RStudio causes this to
completely rebuild RStudio, which is completely unnecessary and also a
bit of a hindrance as it's a fairly slow build.

This rolls back most of that old PR, and instead implements something
more like rWrapper.  Existing configurations with the old useRPackages
will break.
2017-05-01 09:46:40 -04:00
..
patches rPackages: remove old cuda-related patches 2017-02-28 17:31:07 +03:00
bioc-annotation-packages.nix R: 3.2.4 -> 3.3.2 2017-02-24 15:22:12 +11:00
bioc-experiment-packages.nix R: 3.2.4 -> 3.3.2 2017-02-24 15:22:12 +11:00
bioc-packages.nix R: update CRAN and BIOC package sets 2017-04-24 15:39:08 +02:00
cran-packages.nix R: update CRAN and BIOC package sets 2017-04-24 15:39:08 +02:00
default.nix R: update list of broken packages (and some cosmetic) 2017-04-24 15:39:54 +02:00
generate-r-packages.R r-modules: drop broken irkernel package set 2017-03-07 14:56:46 +01:00
generate-shell.nix R: update list of broken packages (and some cosmetic) 2017-04-24 15:39:54 +02:00
generic-builder.nix
README.md rstudio: Fix recompilation issue with custom package set 2017-05-01 09:46:40 -04:00
test-evaluation.nix
wrapper-rstudio.nix rstudio: Fix recompilation issue with custom package set 2017-05-01 09:46:40 -04:00
wrapper.nix rstudio: Fix recompilation issue with custom package set 2017-05-01 09:46:40 -04:00

R packages

Installation

Define an environment for R that contains all the libraries that you'd like to use by adding the following snippet to your $HOME/.config/nixpkgs/config.nix file:

{
    packageOverrides = super: let self = super.pkgs; in
    {

        rEnv = super.rWrapper.override {
            packages = with self.rPackages; [
                devtools
                ggplot2
                reshape2
                yaml
                optparse
                ];
        };
    };
}

Then you can use nix-env -f "<nixpkgs>" -iA rEnv to install it into your user profile. The set of available libraries can be discovered by running the command nix-env -f "<nixpkgs>" -qaP -A rPackages. The first column from that output is the name that has to be passed to rWrapper in the code snipped above.

However, if you'd like to add a file to your project source to make the environment available for other contributors, you can create a default.nix file like so:

let
  pkgs = import <nixpkgs> {};
  stdenv = pkgs.stdenv;
in with pkgs; {
  myProject = stdenv.mkDerivation {
    name = "myProject";
    version = "1";
    src = if pkgs.lib.inNixShell then null else nix;

    buildInputs = with rPackages; [
      R
      ggplot2
      knitr
    ];
  };
}

and then run nix-shell . to be dropped into a shell with those packages available.

RStudio

RStudio uses a standard set of packages and ignores any custom R environments or installed packages you may have. To create a custom environment, see rstudioWrapper, which functions similarly to rWrapper:

{
    packageOverrides = super: let self = super.pkgs; in
    {

        rstudioEnv = super.rstudioWrapper.override {
            packages = with self.rPackages; [
                dplyr
                ggplot2
                reshape2
                ];
        };
    };
}

Then like above, nix-env -f "<nixpkgs>" -iA rstudioEnv will install this into your user profile.

Updating the package set

nix-shell generate-shell.nix

Rscript generate-r-packages.R cran  > cran-packages.nix.new
mv cran-packages.nix.new cran-packages.nix

Rscript generate-r-packages.R bioc  > bioc-packages.nix.new
mv bioc-packages.nix.new bioc-packages.nix

generate-r-packages.R <repo> reads <repo>-packages.nix, therefor the renaming.

Testing if the Nix-expression could be evaluated

nix-build test-evaluation.nix --dry-run

If this exits fine, the expression is ok. If not, you have to edit default.nix