`nix-shell` with `sandbox=true`

As I understand nix-shell just creates environment in terms of available environment variables.

Is it possible to start shell environment with sandboxed file system (nix-build like)?

I’ve tried buildFHSEnv, but it keeps many folders at / from the system environment and I’ve seen comments that it wasn’t exactly designed to create completely sandboxed file system environment.

Nix does not have something like that.

But maybe hover or hover-rs do what you need, or can at least be used as a base to build something on your own.

I never used either, just am aware of the existence.

Isn’t usually a problem for debugging failed builds or there is some workaround?

E.g. when nix-build --keep-failed is failed and user goes to investigate what happened to the build directory and even if they use nix-shell --pure package.nix they will be debugging in a sllightly different environment than was used for the build, since file system is not sandboxed and system dependencies may get in the way.

I think that breakpointHook is probably what you’re looking for.

1 Like

Thanks, that’s a great option - I can force fail the build to get sandboxed shell for some tests.
Sadly, it’s not available on Mac though.