I am on a debian jessy without root-access. So I am using nix in a single-user install with proot.
I had problems with derivations using writeText
from nixpkgs. The error is very weird, so I tried to finde a minimal failing example:
$ cat fail.nix
with import <nixpkgs> {};
runCommand "test-file-name"
{
text="test text";
passAsFile = [ "text" ];
}
''
if [[ -f "$textPath" ]]; then
echo "$textPath exists with content:"
cat "$textPath"
echo ""
fi
if [[ -d "$(dirname "$out")" ]]; then
echo "dir $(dirname "$out") exists"
fi
mv "$textPath" "$out"
''
this fails like this:
$ nix-build fail.nix
these derivations will be built:
/nix/store/vas4dyknw73mx3hyj2l5k0znw1bq4z64-test-file-name.drv
building '/nix/store/vas4dyknw73mx3hyj2l5k0znw1bq4z64-test-file-name.drv'...
/tmp/user/18050/nix-build-test-file-name.drv-0/.attr-0 exists with content:
test text
dir /nix/store exists
mv: cannot move '/tmp/user/18050/nix-build-test-file-name.drv-0/.attr-0' to '/nix/store/xfm2pqsn21awy0rjk2xb1ddqw4nm31hz-test-file-name': No such file or directory
builder for '/nix/store/vas4dyknw73mx3hyj2l5k0znw1bq4z64-test-file-name.drv' failed with exit code 1
error: build of '/nix/store/vas4dyknw73mx3hyj2l5k0znw1bq4z64-test-file-name.drv' failed
So mv
seems to be complaining that the target of the move does not exist. This strikes me as odd, since that is quite usual when using mv
. To confirm this suspicion I can add a touch
:
<same as before>
touch "$out"
mv "$textPath" "$out"
''
now it works:
$ nix-build fail.nix
/nix/store/95w5g1d9nbvclbpyhq74mfpl6i4b70ci-test-file-name
I can only speculate that this might be a problem with proot
and the fact, that /tmp
and /nix
reside on different filesystems …
I would be glad for any insights on what I can do besides using a fork of nixpkgs with a completely unreasonable touch
added to writeText
.