nix-build:bash 权限被拒绝

nix-build: bash permission denied

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

所以我的目录只有这个 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 回显进行简单推导的正确方法是什么?

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

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

提前致谢。

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

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