mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 05:00:58 +01:00
* nix-store, nix-instantiate: added an option `--add-root' to
immediately add the result as a permanent GC root. This is the only
way to prevent a race with the garbage collector. For instance, the
old style
ln -s $(nix-store -r $(nix-instantiate foo.nix)) \
/nix/var/nix/gcroots/result
has two time windows in which the garbage collector can interfere
(by GC'ing the derivation and the output, respectively). On the
other hand,
nix-store --add-root /nix/var/nix/gcroots/result -r \
$(nix-instantiate --add-root /nix/var/nix/gcroots/drv \
foo.nix)
is safe.
* nix-build: use `--add-root' to prevent GC races.
This commit is contained in:
parent
a6b65fd5e1
commit
dcc37c236c
11 changed files with 165 additions and 17 deletions
|
|
@ -168,7 +168,7 @@ void copyPath(const Path & src, const Path & dst)
|
|||
}
|
||||
|
||||
|
||||
static bool isInStore(const Path & path)
|
||||
bool isStorePath(const Path & path)
|
||||
{
|
||||
return path[0] == '/'
|
||||
&& path.compare(0, nixStore.size(), nixStore) == 0
|
||||
|
|
@ -180,7 +180,7 @@ static bool isInStore(const Path & path)
|
|||
|
||||
void assertStorePath(const Path & path)
|
||||
{
|
||||
if (!isInStore(path))
|
||||
if (!isStorePath(path))
|
||||
throw Error(format("path `%1%' is not in the Nix store") % path);
|
||||
}
|
||||
|
||||
|
|
@ -579,7 +579,7 @@ void verifyStore()
|
|||
if (!pathExists(path)) {
|
||||
printMsg(lvlError, format("path `%1%' disappeared") % path);
|
||||
invalidatePath(path, txn);
|
||||
} else if (!isInStore(path)) {
|
||||
} else if (!isStorePath(path)) {
|
||||
printMsg(lvlError, format("path `%1%' is not in the Nix store") % path);
|
||||
invalidatePath(path, txn);
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue