I know that I can build a derivation in nix-shell
by hand for debugging purposes. When I do:
nix-shell '<nixpkgs>' -A hello
> genericBuild
I get back a hello-${version}
subfolder in which the binary is built. That makes sense to me.
But in other builds, like for example one using buildGoPackage
there’s a command that changes directory to NIX_BUILD_TOP
:
Which results in me ending up in /run/user/1000
, which is the default value for NIX_BUILD_TOP
on my system when I start a nix-shell
.
I’m wondering:
- Is there some canonical way to tell
nix-shell
to use a specific build folder? - Should derivations reference
NIX_BUILD_TOP
in their steps like that? - Why is
nix-shell
ignoring my setNIX_BUILD_TOP
when I use--keep
?
> NIX_BUILD_TOP=/tmp/build nix-shell '<nixpkgs>' --keep NIX_BUILD_TOP -A hello
[nix-shell:~]$ echo $NIX_BUILD_TOP
/run/user/1000