mirror of
https://github.com/NixOS/nix.git
synced 2025-12-03 07:31:00 +01:00
Implement alternative to lazy generations:
* only the last generation can be lazy * depend on the '--lazy-generation' flag to be set
This commit is contained in:
parent
3d83188702
commit
ea39c98d41
6 changed files with 39 additions and 21 deletions
|
|
@ -74,7 +74,7 @@ static void makeName(const Path & profile, unsigned int num,
|
|||
}
|
||||
|
||||
|
||||
Path createGeneration(Path profile, Path outPath)
|
||||
Path createGeneration(Path profile, Path outPath, bool lazy)
|
||||
{
|
||||
/* The new generation number should be higher than old the
|
||||
previous ones. */
|
||||
|
|
@ -83,13 +83,16 @@ Path createGeneration(Path profile, Path outPath)
|
|||
|
||||
unsigned int num;
|
||||
if (gens.size() > 0) {
|
||||
/* Check existing generations whether they represent an
|
||||
environment we already materialized before. In that case:
|
||||
avoid cluttering the system with additional symlinks. */
|
||||
for (auto & gen : gens) {
|
||||
if (readLink(gen.path) == outPath) {
|
||||
return gen.path;
|
||||
}
|
||||
Generation last = gens.back();
|
||||
|
||||
if (lazy && readLink(last.path) == outPath) {
|
||||
/* If lazy generations are enabled then we only create a
|
||||
new generation symlink if it differs from the last one.
|
||||
|
||||
This helps keeping gratuitous installs/rebuilds from piling
|
||||
up uncontrolled numbers of generations, cluttering up the
|
||||
UI like grub. */
|
||||
return last.path;
|
||||
}
|
||||
|
||||
num = gens.back().number;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue