foo = pkgs.writeTextDir "foo" "foo";
bar = pkgs.writeTextDir "bar" "bar";
baz = pkgs.runCommand "baz" {} ''
mkdir $out
cp -a ${foo}/. $out
cp -a ${bar}/. $out
'';
Trying to build baz
, I get the following error:
builder for '/nix/store/fq1a7km4cd7nqgry1zjsxgg6hps507wl-baz.drv' failed with exit code 1; last 1 log lines:
cp: cannot create regular file '/nix/store/325c0jnxhbjha333bqfrcksiwkv5i059-baz/./bar': Permission denied
Weirdly, copying foo
to $out
went fine:
$ ls /nix/store/325c0jnxhbjha333bqfrcksiwkv5i059-baz
foo
This confuses me: why should the copying only be allowed once? Is there a good reason for this restriction or could this be a bug in nix(pkgs)? Thanks!