stdenv setup: disallow references to the build directory#21287
stdenv setup: disallow references to the build directory#21287joachifm wants to merge 3 commits intoNixOS:masterfrom
Conversation
Original commit: NixOS@e52a6a2
|
I'm unsure how this interacts with multiple outputs, if at all. (EDIT: in the sense that I naively expect it to be extended to cover all possible outputs, not just |
|
It seems to me it won't work for multiple outputs as it is -- but you may iterate over |
|
It now iterates over all the outputs |
|
I wonder if there's ever a legitimate reason to capture the build toplevel? If not, maybe we could make it only conditional on |
|
Not sure if that counts as "legitimate" but any package containing debug information will have references to its build paths (for binary text to source code lines mappings). We probably want to disable this in |
|
Is it feasible to patch those references to a fixed path? (EDIT: or even desirable) |
|
It's a good idea but I'm not sure we can do it. Surely |
|
I like the mount namespace idea, seems like it would solve the problem "for real". |
|
I have trouble parsing the variable name Also, this functionality would be better to handle in Nix itself, which scans the outputs anyway. Now we're doing twice the I/O. |
|
@edolstra I can't speak to the motivation for the variable naming, but doing this in Nix itself makes sense. |
|
It seems I was mistaken -- we do already use a constant build directory when we are in a sandbox! It'll still be nice to detect and prevent unwanted references to build directories -- I agree it'd better done in Nix. |
|
@abbradar ah, so this is basically a solved problem for sandboxed builds? |
|
It seems so (but we still want to control where build references are allowed I think -- so this PR/Nix issue is still relevant). |
|
I always imagined that build dirs be Nix store paths. Then, for instance, the debug output can reference the build dir and all source lookup from debuginfo will Just Work. |
|
That would be possible, but you typically don't want the binaries depend on source files (i.e. keep them alive). |
|
Right. I think perhaps Nix could learn about "weak" references. |
|
The general contention about weak references is that they break purity (slightly). Note that there are ways to use weak references already, via obfuscating them, e.g. #15539. |
Extracted from #2281
Unfortunately, I lack the capacity for testing this, hopefully somebody is able and willing to do so in my stead (if this is something we want to do).