【发布时间】:2020-10-19 14:29:57
【问题描述】:
我想创建一个foo.nix 文件,当您nix-shell foo.nix 并进入沙盒外壳时,PATH 包含一些其他派生的bin/ 子目录。我该怎么做?
--- 最小的可重现示例 ---
以下是我迄今为止最好的尝试。
这是我当前的 .nix 文件
let git = builtins.fetchGit {
url = https://github.com/ingun37/haskell-script.git;
rev = "e96ac79d6bf338c98697bb4ba510f22cb5f502ac";
};
haskellScriptD = import git {};
in derivation {
name = "a"; # giving any name because I won't actually build it.
builder = "a"; # Same here
system = builtins.currentSystem;
script = haskellScriptD;
}
这就是我为了在派生的bin/ 子目录中运行可执行文件而运行的。您可以看到我必须在可执行文件之前附加路径,因为我不知道如何配置 PATH。
nix-shell a.nix --run "\$script/bin/json-generator"
我要运行的是
nix-shell a.nix --run json-generator
我该怎么做?
【问题讨论】:
-
您是真的在使用
derivation还是在使用stdenv.mkDerivation?您能否使用 nixpkgs 中的软件包提供 minimal reproducible example 而不是伪代码?这会很方便,因为我可以尝试编辑它的几行来尝试一些不同的想法,看看它们是否有效。 -
@DavidGrayson 我使用推导。
-
@DavidGrayson 我编辑了帖子以包含我使用的实际 nix 代码。
-
@DavidGrayson 当我没有实际构建它时,使用 mkDerivation 有什么意义吗?我只用它来设置沙盒外壳。
-
嗯...您的最小示例从 Internet 中提取未知代码并运行它。无论如何,我认为您可以执行类似使用 stdenv.mkDerivation 之类的操作,并将您感兴趣的程序添加到
input或nativeInputs属性中,这些属性应该是派生列表。
标签: nix