Nix: NIX_BUILD_TOP not set correctly outside of nixos

Created on 12 Oct 2019  路  4Comments  路  Source: NixOS/nix

https://gist.github.com/a0722abf36a1cfc5cadf8e39c356fba5

for some weird reason, if the sandbox is on, but nix cant get root, then the working dir, and the $NIX_BUILD_TOP wont agree on the directory

this results in things like runCommand being unable to follow $buildCommandPath and then complaining about you needing to set src or srcs

Most helpful comment

For posterity, to work around the issue, pass --option sandbox false to the nix command you're running.

Edit: I've also now updated to nix 2.3.7 and the issue is resolved. I'm not sure what the first version containing that fix is though.

All 4 comments

A user on IRC just encountered this, the error was

building '/nix/store/31yjixwkm35d6m2yqg3qdf367i06vvf0-kernel-modules.drv'...
/nix/store/95j91i5mkhfwqrscmiz49qab3l343jc7-stdenv-linux/setup: line 810: /build/env-vars: No such file or directory
created 3 symlinks in user environment
/nix/store/95j91i5mkhfwqrscmiz49qab3l343jc7-stdenv-linux/setup: line 313: pkgBuildAccumVars: readonly variable
[...]
/nix/store/95j91i5mkhfwqrscmiz49qab3l343jc7-stdenv-linux/setup: line 352: allPlatOffsets: readonly variable
/nix/store/95j91i5mkhfwqrscmiz49qab3l343jc7-stdenv-linux/setup: line 797: /build/env-vars: No such file or directory
kernel version is 4.19.78
building '/nix/store/wiq4rchmxckzkyvlz09lw6r0x7f3vp65-hwdb.bin.drv'...
/nix/store/95j91i5mkhfwqrscmiz49qab3l343jc7-stdenv-linux/setup: line 810: /build/env-vars: No such file or directory
unpacking sources
/nix/store/95j91i5mkhfwqrscmiz49qab3l343jc7-stdenv-linux/setup: line 810: /build/env-vars: No such file or directory
variable $src or $srcs should point to the source
builder for '/nix/store/wiq4rchmxckzkyvlz09lw6r0x7f3vp65-hwdb.bin.drv' failed with exit code 1
cannot build derivation '/nix/store/jdsra676zymclc25z5yjn395jxkk7dpw-etc.drv': 1 dependencies couldn't be built
building '/nix/store/d0nnk98k3haz7mj7ignqk1givcy21ard-linux-4.19.78-modules.drv'...
cannot build derivation '/nix/store/5va0q68d872ppqn3zw1w9la7hxizqrlq-nixos-system-vulcan-19.09.741.dbad7c7d59f.drv': 1 dependencies couldn't be built
error: build of '/nix/store/5va0q68d872ppqn3zw1w9la7hxizqrlq-nixos-system-vulcan-19.09.741.dbad7c7d59f.drv' failed

Logs including solution: https://logs.nix.samueldr.com/nixos/2019-10-12#1570910798-1570911855;

Yeah this looks like a mistake I made in https://github.com/NixOS/nix/pull/3006. I think https://github.com/NixOS/nix/pull/3144 fixes this.

For posterity, to work around the issue, pass --option sandbox false to the nix command you're running.

Edit: I've also now updated to nix 2.3.7 and the issue is resolved. I'm not sure what the first version containing that fix is though.

I'm not sure what the first version containing that fix is though.

It's fixed not in 2.3.1 but in 2.3.2; this is the commit in that release: https://github.com/NixOS/nix/commit/10bf5340ca35269153aca67ecd35f5419d0a08bc

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chexxor picture chexxor  路  4Comments

matthewbauer picture matthewbauer  路  3Comments

eqyiel picture eqyiel  路  3Comments

luc65r picture luc65r  路  3Comments

dasJ picture dasJ  路  3Comments