nix-build:bash权限被拒绝

时间:2017-06-08 18:23:09

标签: nix

我正在努力学习编写Nix表达式,并且我想要自己做一个非常简单的" Hello World!" (按照传统)。

所以我的dir只有这个default.nix文件:

{pkgs ? import <nixpkgs> {}}:
derivation {
    system = "x86_64-linux";
    name = "simple-bash-derivation-helloworld";
    builder = pkgs.bash;
    args = [ "-c" "echo 'Hello World' > $out" ];
}

这是我尝试构建它时得到的结果:

nix-build
these derivations will be built:
  /nix/store/3grmahx3ih4c50asj84p7xnpqpj32n5s-simple-bash-derivation-helloworld.drv
building path(s) ‘/nix/store/6psl3rc92311w37c1n6nj0a6jac16hv1-simple-bash-derivation-helloworld’
while setting up the build environment: executing ‘/nix/store/wb34dgkpmnssjkq7yj4qbjqxpnapq0lw-bash-4.4-p12’: Permission denied
builder for ‘/nix/store/3grmahx3ih4c50asj84p7xnpqpj32n5s-simple-bash-derivation-helloworld.drv’ failed with exit code 1
error: build of ‘/nix/store/3grmahx3ih4c50asj84p7xnpqpj32n5s-simple-bash-derivation-helloworld.drv’ failed

删除args行会产生同样的问题。

为什么我会收到权限问题? 使用bash echo进行简单推导的正确方法是什么?

请注意,这是一项学习练习:例如,我不想在这里使用stdenv.mkDerivation

我在Ubuntu 16.04系统上运行nix-env (Nix) 1.11.9

提前致谢。

1 个答案:

答案 0 :(得分:2)

尝试在ls上运行/nix/store/wb34dgkpmnssjkq7yj4qbjqxpnapq0lw-bash-4.4-p12命令,您将看到它是一个目录而不是一个可执行文件(指向$out派生的pkgs.bash。如果您想引用bash二进制文件,您可以使用:

builder = "${pkgs.bash}/bin/bash";