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

Enable lazy/sparse allocation of generation symlinks: avoid creating

new generations if a generation already exists.

Alternatively or additionally I propose a mode where only the *last* generation will be sparse.
This commit is contained in:
Christian Theune 2015-05-18 08:38:49 +02:00
parent be1ff23352
commit 3d83188702
2 changed files with 25 additions and 1 deletions

View file

@ -80,7 +80,22 @@ Path createGeneration(Path profile, Path outPath)
previous ones. */
int dummy;
Generations gens = findGenerations(profile, dummy);
unsigned int num = gens.size() > 0 ? gens.back().number : 0;
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;
}
}
num = gens.back().number;
} else {
num = 0;
}
/* Create the new generation. Note that addPermRoot() blocks if
the garbage collector is running to prevent the stuff we've