From 00fe1a506f045e612b0564ab0b5aff3917e26bd3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 11 Feb 2004 10:25:31 +0000 Subject: [PATCH] * 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. --- src/nix-env/main.cc | 2 +- src/nix-env/profiles.cc | 11 +++++++---- src/nix-env/profiles.hh | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index 673d1b2be..07a49a122 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -196,7 +196,7 @@ void createUserEnv(EvalState & state, const DrvInfos & drvs, /* Switch the current user environment to the output path. */ debug(format("switching to new user environment")); Path generation = createGeneration(profile, - topLevelDrv.outPath, topLevelDrv.drvPath); + topLevelDrv.outPath, topLevelDrv.drvPath, nfPath); switchLink(profile, generation); } diff --git a/src/nix-env/profiles.cc b/src/nix-env/profiles.cc index a1e0c94a9..d47c528b2 100644 --- a/src/nix-env/profiles.cc +++ b/src/nix-env/profiles.cc @@ -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 previous ones. */ @@ -67,12 +68,13 @@ Path createGeneration(Path profile, Path outPath, Path drvPath) unsigned int num = gens.size() > 0 ? gens.front().number : 0; /* Create the new generation. */ - Path generation, gcrootSrc; + Path generation, gcrootDrv, gcrootClr; while (1) { Path prefix = (format("%1%-%2%") % profile % num).str(); 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 (errno != EEXIST) throw SysError(format("creating symlink `%1%'") % generation); @@ -80,7 +82,8 @@ Path createGeneration(Path profile, Path outPath, Path drvPath) num++; } - writeStringToFile(gcrootSrc, drvPath); + writeStringToFile(gcrootDrv, drvPath); + writeStringToFile(gcrootClr, clrPath); return generation; } diff --git a/src/nix-env/profiles.hh b/src/nix-env/profiles.hh index 2ce468dfa..423134412 100644 --- a/src/nix-env/profiles.hh +++ b/src/nix-env/profiles.hh @@ -28,7 +28,8 @@ typedef list Generations; profile, sorted by generation number. */ 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);