ropensci / rix

Reproducible Data Science environments for R with Nix
https://docs.ropensci.org/rix/
GNU General Public License v3.0
180 stars 15 forks source link

Change dots to underscores in dependencies of R-packages built from github. #70

Closed motorlearner closed 1 year ago

motorlearner commented 1 year ago

See below: cmdstanr is built from github and depends on data.table, which should be specified as data_table in the propagatedBuildInputs.

remotes::install_github("b-rodrigues/rix")

library(rix)

rix(
  r_ver = "latest",
  r_pkgs = c("data.table"),
  system_pkgs = c("cmdstan"),
  git_pkgs = list(
    list( # build cmdstanr package from github
      package_name = "cmdstanr",
      repo_url = "https://github.com/stan-dev/cmdstanr",
      branch_name = "master",
      commit = "5e2551c7a5f40434e858f18d9dbfb50444583696"
    )
  ),
  ide = "code",
  overwrite = TRUE,
  shell_hook = 'export CMDSTAN=$(dirname $(dirname "$(which stan)"))/opt/cmdstan'
)
let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/b200e0df08f80c32974a6108ce431d8a8a5e6547.tar.gz") {};
 rpkgs = builtins.attrValues {
  inherit (pkgs.rPackages) data_table languageserver;
};
 git_archive_pkgs = [(pkgs.rPackages.buildRPackage {
    name = "cmdstanr";
    src = pkgs.fetchgit {
      url = "https://github.com/stan-dev/cmdstanr";
      branchName = "master";
      rev = "5e2551c7a5f40434e858f18d9dbfb50444583696";
      sha256 = "sha256-afoITk2TGOwIoHcAZhNS2hgDmMAj1OkTPZHTif+U0Xo=";
    };
    propagatedBuildInputs = builtins.attrValues {
      inherit (pkgs.rPackages) checkmate data.table jsonlite posterior processx R6 withr; # should be data_table
    };
  }) ];
 system_packages = builtins.attrValues {
  inherit (pkgs) R cmdstan;
};
  in
  pkgs.mkShell {
    buildInputs = [ git_archive_pkgs rpkgs system_packages  ];
      shellHook = ''
export CMDSTAN=$(dirname $(dirname "$(which stan)"))/opt/cmdstan
'';
  }
b-rodrigues commented 1 year ago

thanks! I thought this was dealt with but seem I forgot to make it work for deps of Github packages! I'll solve asap

b-rodrigues commented 1 year ago

thanks, solved with https://github.com/b-rodrigues/git2nixsha/commit/f9ef556929ec7f00cc4a02d103a71d836c6e6129