[Nix-dev] [PATCH] Allow roots to refer to arbitrary files in the store

Eelco Dolstra eelco.dolstra at logicblox.com
Tue Apr 15 15:48:08 CEST 2014


Hi,

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.

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list