Interactive access to a build environment?

For debugging derivations, I’d like something like nix-shell, but that drops me in the temporary build directory that nix-build uses. Is there a way to do that? Maybe an option to either nix-shell or nix-build?

I guess I can just use mktemp myself… Leaves me worried I’m missing something though.

I end up doing something like this a lot:

cd /tmp && nix-shell '<nixpkgs>' -A hello --run genericBuild

Perhaps Nix should have some builtin option to set this up for you though.


How would you specify overlays in this command?

Here is an example of a completely pointless overlay, but you get the idea:

nix-shell '<nixpkgs>' --arg overlays '[ (final: prev: { foobar = final.hello; }) ]' -A foobar

Of course you can also import and overlay from a file:

nix-shell '<nixpkgs>' --arg overlays '[ (import ./my-overlay.nix) ]' -A foobar
1 Like