两个相关问题:
1.如何在configuration.nix中安装R和选定的软件包?
2.如何不仅从CRAN,而且从Gitub或至少本地存储的软件包中添加软件包?
在Wiki中,您会找到类似的说明来安装R软件包。 https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/r.section.md。使用nix-shell
时可以正常使用,但是在尝试从configuration.nix进行安装时遇到问题。
关于构建R包,我发现了有关构建包的以下示例:
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.
但是想将所有从configuration.nix运行到一个位置的机器配置。
答案 0 :(得分:0)
好吧,借助上面的Bulats指针,我设法找到了解决方案。在此处找到了完整的示例:https://github.com/NixOS/nixpkgs/issues/44290
为了将来参考,这是在configuration.nix中从CRAN和Github内联添加r包的一种方法:
environment.systemPackages = with pkgs;
[(pkgs.rWrapper.override {
packages = with pkgs.rPackages; let
llr = buildRPackage {
name = "llr";
src = pkgs.fetchFromGitHub {
owner = "dirkschumacher";
repo = "llr";
rev = "0a654d469af231e9017e1100f00df47bae212b2c";
sha256 = "0ks96m35z73nf2sb1cb8d7dv8hq8dcmxxhc61dnllrwxqq9m36lr";};
propagatedBuildInputs = [ rlang knitr];
nativeBuildInputs = [ rlang knitr ];};
in [knitr
rlang
llr
tidyverse
## the rest of your R packages here
devtools];})
pkgs.postgresql
pkgs.isync
pkgs.msmtp
pkgs.notmuch
gnupg
## the rest of your Nixos packages (derivations) here
];