1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 04:01:47 +02:00

* Get garbage collection and cache population to work *properly*.

Renamed `fstateRefs' to `fstateRequisites'.  The semantics of this
  function is that it returns a list of all paths necessary to realise
  a given expression.  For a derive expression, this is the union of
  requisites of the inputs; for a slice expression, it is the path of
  each element in the slice.  Also included are the paths of the
  expressions themselves.  Optionally, one can also include the
  requisites of successor expressions (to recycle intermediate
  results).

* `nix-switch' now distinguishes between an expression and its normal
  form.  Usually, only the normal form is registered as a root of the
  garbage collector.  With the `--source-root' flag, it will also
  register the original expression as a root.

* `nix-collect-garbage' now has a flag `--keep-successors' which
  causes successors not to be included in the list of garbage paths.

* `nix-collect-garbage' now has a flag `--invert' which will print all
  paths that should *not* be garbage collected.
This commit is contained in:
Eelco Dolstra 2003-07-29 14:28:17 +00:00
parent dc14a3de46
commit 8846465934
7 changed files with 85 additions and 29 deletions

View file

@ -244,7 +244,8 @@ Strings fstatePaths(const FSId & id)
}
static void fstateRefsSet(const FSId & id, StringSet & paths)
static void fstateRequisitesSet(const FSId & id,
bool includeExprs, bool includeSuccessors, StringSet & paths)
{
FState fs = parseFState(termFromId(id));
@ -257,17 +258,28 @@ static void fstateRefsSet(const FSId & id, StringSet & paths)
else if (fs.type == FState::fsDerive) {
for (FSIds::iterator i = fs.derive.inputs.begin();
i != fs.derive.inputs.end(); i++)
fstateRefsSet(*i, paths);
fstateRequisitesSet(*i,
includeExprs, includeSuccessors, paths);
}
else abort();
if (includeExprs)
paths.insert(expandId(id));
string idSucc;
if (includeSuccessors &&
queryDB(nixDB, dbSuccessors, id, idSucc))
fstateRequisitesSet(parseHash(idSucc),
includeExprs, includeSuccessors, paths);
}
Strings fstateRefs(const FSId & id)
Strings fstateRequisites(const FSId & id,
bool includeExprs, bool includeSuccessors)
{
StringSet paths;
fstateRefsSet(id, paths);
fstateRequisitesSet(id, includeExprs, includeSuccessors, paths);
return Strings(paths.begin(), paths.end());
}