[Nix-dev] Developing R modules with nix

Michel Kuhlmann michel at kuhlmanns.info
Wed Sep 24 07:15:00 CEST 2014


Thanks Peter for the very helpful answers. I have some follow-up
questions:

- Is it possible to make the package-executables available in the
  search-PATH, when installing with `nix`? For example me, I put the
  executables which are based on the package-library into the
  `exec`-folder (see 1.1.5 [1]).  My scripts usually use 
  `#!/usr/bin/env Rscript`; I guess this would have to be patched.

  [1]: http://cran.r-project.org/doc/manuals/R-exts.html

- Workflow for developing personal R-package projects. In Haskell I've
  seen the following  pattern:

    /projects/foobar/shell.nix
       let
           pkgs = import <nixpkgs> {};
           haskellPackages = pkgs.haskellPackages.override {
               extension = self: super: {
                   foobar = self.callPackage ./. {};
               };
           };
        in 
            pkgs.lib.overrideDerivation haskellPackages.foobar(attrs: {
                buildInputs = [ haskellPackages.cabalInstall ] ++ attrs.buildInputs;
            }) 

    /projects/foobar/default.nix
        { cabal, text, attoparsec }:
        cabal.mkDerivation (self: {
        pname = "foobar";
        src = ./.;
        version = "1.0";
        buildDepends = [ text attoparsec ];
        })

    $HOME/.nixpkgs/config.nix 
        haskellProjects = { self, super, callPackage }: rec {
          foobar = callPackage /projects/foobar {};
          };

        haskellPackages_wrapper = hp: self.recurseIntoAttrs (hp.override {
            extension = this: super: haskellProjects {
              self = this;
              super = super;
              callPackage = self.lib.callPackageWith this;
            };
          });

        haskellPackages_ghc783 =
          haskellPackages_wrapper (recurseIntoAttrs haskell.packages_ghc783.noProfiling);

  Then I could install foobar with 
       nix-env -iA nixpkgs.haskellPackages.foobar

  Could you give me a hint how to accomplish an analog behavior for my personal R-packages?

  Thanks, Michel


More information about the nix-dev mailing list