Eelco Dolstra <eelco.dols...@logicblox.com> skribis: > On 14/04/14 16:59, Ludovic Courtès wrote: > >>>>> The patch below allows files such as /nix/store/foo to be protected from >>>>> GC if a root refers to them. This makes it easy for a build hook to use >>>>> such files for its temporary working files. >>>>> >>>>> WDYT? >>>> >>>> It seems a bit odd to me to be using the store as a temporary file >>>> location. What's wrong with $TMPDIR? >>> >>> Well, this is useful for build hooks, because it guarantees that any >>> garbage they leave there will eventually be reclaimed. >> >> It also guarantees that this thing lives on the same file system as the >> store, which means that rename(2) can be used to move it to its final >> location in the store. > > The problem with your patch is that those roots don't get cleaned up > automatically. A better solution is to generalize the handling of temporary > store paths like lock files and chroot directories; check out the calls to > isActiveTempFile() in tryToDelete() in gc.cc. Those don't get deleted while > the > associated build is still running, but do get deleted afterwards.
Hmm yes, I know. I wanted to avoid going at lengths to expose all that but OK. That raises the barrier for build hook implementors... Thanks, Ludo’.