[英]How do you add a local R package using Nix package manager
Let's say that I have a local R package that lives at /home/placey/messyverse.tar.gz
假设我有一个本地R包,位于
/home/placey/messyverse.tar.gz
I'd like to start up a nix shell that contains my package as well as ggplot. 我想启动一个包含我的包和ggplot的nix shell。 How do I do that?
我怎么做?
First we need to create a nix package that contains the necessary information for your local package. 首先,我们需要创建一个nix软件包,其中包含本地软件包的必要信息。
Lets call it 让我们称之为
messverse.nix
with import <nixpkgs> {};
{
messverse = rPackages.buildRPackage rec {
name = "messverse";
version = "0.1";
src = /home/placey/messverse.tar.gz;
buildInputs = with rPackages; [
R
stringr
];
};
}
Then in the same folder we will create the default.nix
that defnes what is needed for the nix shell. 然后,在同一文件夹中,我们将创建
default.nix
来定义nix shell所需的内容。
default.nix
with import <nixpkgs> {};
with import ./messyverse.nix;
{
myProject = stdenv.mkDerivation {
name = "myProject";
version = "1";
src = if pkgs.lib.inNixShell then null else nix;
buildInputs = with rPackages; with messyverse; [
R
ggplot2
messyverse
];
};
}
now we can execute nix-shell .
现在我们可以执行
nix-shell .
and we have a shell which contains R & our locally specified R package! 我们有一个包含R和我们本地指定的R包的外壳!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.