[Nix-dev] Developing R modules with nix

Michel Kuhlmann michel at kuhlmanns.info
Mon Sep 15 08:24:40 CEST 2014


Hi Peter,
 
>  > Currently I have in my `.nixpkgs/config.nix` an entry with
>  >
>  >     rToolsEnv = pkgs.buildEnv {
>  >         name = "rTools";
>  >         paths = with rPackages; [
>  >             devtools
>  >             ggplot2
>  >         ];
>  >       };
>  >
>  > and I am installing it with `nix-env -i rTools`
> 
> interesting ... why do you prefer that approach? I would have used
> 
>   rWrapper = super.rWrapper.override {
>     packages = with self.rPackages; [ devtools ggplot2 ]
>   };
> 

In the first place I was trying the approach listed on the mailing list [1]:

    {
      packageOverrides = pkgs: {
        rWrapper = pkgs.rWrapper.override {
          packages = with pkgs.rPackages; [ Defaults data_table ];
        };
      };
    }

which didn't immediately work out; this is why I used John's [2] approach,
which did. 

[1]: http://www.mail-archive.com/nix-dev%40lists.science.uu.nl/msg11757.html
[2]: https://github.com/jwiegley/nix-config/blob/master/config.nix


> I'm not much of an R developer, so I cannot say much about this subject.
> A default.nix that you could use to build your local project with Nix
> is:
> 
>  | let
>  |
>  |   pkgs = import <nixpkgs> {};
>  |   buildRPackage = import <nixpkgs/pkgs/development/r-modules/generic-builder.nix> pkgs.R;
>  |
>  | in
>  |
>  | with pkgs.rPackages;
>  |
>  | {
>  |   foobar = buildRPackage {
>  |     name = "your-package-name-1.0";
>  |     src = ./.;
>  |     propagatedBuildInputs = [/* required dependencies go here */];
>  |   };
>  | }
> 
> The command "nix-build . -A foobar" would then compile it.
> 
> I hope this helps,

Thanks a lot; this helped,

Michel


More information about the nix-dev mailing list