* When creating a new generation, also make the normal form of the
derivation (i.e., the closure store expression) a root of the garbage collector. This ensures that running `nix-collect-garbage --no-successors' is safe.
This commit is contained in:
parent
92e832348d
commit
00fe1a506f
|
@ -196,7 +196,7 @@ void createUserEnv(EvalState & state, const DrvInfos & drvs,
|
||||||
/* Switch the current user environment to the output path. */
|
/* Switch the current user environment to the output path. */
|
||||||
debug(format("switching to new user environment"));
|
debug(format("switching to new user environment"));
|
||||||
Path generation = createGeneration(profile,
|
Path generation = createGeneration(profile,
|
||||||
topLevelDrv.outPath, topLevelDrv.drvPath);
|
topLevelDrv.outPath, topLevelDrv.drvPath, nfPath);
|
||||||
switchLink(profile, generation);
|
switchLink(profile, generation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,8 @@ Generations findGenerations(Path profile, int & curGen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path createGeneration(Path profile, Path outPath, Path drvPath)
|
Path createGeneration(Path profile, Path outPath,
|
||||||
|
Path drvPath, Path clrPath)
|
||||||
{
|
{
|
||||||
/* The new generation number should be higher than old the
|
/* The new generation number should be higher than old the
|
||||||
previous ones. */
|
previous ones. */
|
||||||
|
@ -67,12 +68,13 @@ Path createGeneration(Path profile, Path outPath, Path drvPath)
|
||||||
unsigned int num = gens.size() > 0 ? gens.front().number : 0;
|
unsigned int num = gens.size() > 0 ? gens.front().number : 0;
|
||||||
|
|
||||||
/* Create the new generation. */
|
/* Create the new generation. */
|
||||||
Path generation, gcrootSrc;
|
Path generation, gcrootDrv, gcrootClr;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
Path prefix = (format("%1%-%2%") % profile % num).str();
|
Path prefix = (format("%1%-%2%") % profile % num).str();
|
||||||
generation = prefix + "-link";
|
generation = prefix + "-link";
|
||||||
gcrootSrc = prefix + "-src.gcroot";
|
gcrootDrv = prefix + "-drv.gcroot";
|
||||||
|
gcrootClr = prefix + "-clr.gcroot";
|
||||||
if (symlink(outPath.c_str(), generation.c_str()) == 0) break;
|
if (symlink(outPath.c_str(), generation.c_str()) == 0) break;
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
throw SysError(format("creating symlink `%1%'") % generation);
|
throw SysError(format("creating symlink `%1%'") % generation);
|
||||||
|
@ -80,7 +82,8 @@ Path createGeneration(Path profile, Path outPath, Path drvPath)
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeStringToFile(gcrootSrc, drvPath);
|
writeStringToFile(gcrootDrv, drvPath);
|
||||||
|
writeStringToFile(gcrootClr, clrPath);
|
||||||
|
|
||||||
return generation;
|
return generation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ typedef list<Generation> Generations;
|
||||||
profile, sorted by generation number. */
|
profile, sorted by generation number. */
|
||||||
Generations findGenerations(Path profile, int & curGen);
|
Generations findGenerations(Path profile, int & curGen);
|
||||||
|
|
||||||
Path createGeneration(Path profile, Path outPath, Path drvPath);
|
Path createGeneration(Path profile, Path outPath,
|
||||||
|
Path drvPath, Path clrPath);
|
||||||
|
|
||||||
void switchLink(Path link, Path target);
|
void switchLink(Path link, Path target);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue