about summary refs log tree commit diff
path: root/src/nix-env/profiles.cc
diff options
context:
space:
mode:
authorChristian Theune <ct@flyingcircus.io>2015-05-19T18·03+0200
committerChristian Theune <ct@flyingcircus.io>2015-05-19T18·03+0200
commitea39c98d419a816029299b99f70455798e66f6b7 (patch)
tree9cdea14533783e93e0c7b1a4972bb6c58adb5edf /src/nix-env/profiles.cc
parent3d8318870289d7b6b08677fcd2da6ceb0b082f8c (diff)
Implement alternative to lazy generations:
* only the last generation can be lazy
* depend on the '--lazy-generation' flag to be set
Diffstat (limited to 'src/nix-env/profiles.cc')
-rw-r--r--src/nix-env/profiles.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nix-env/profiles.cc b/src/nix-env/profiles.cc
index 1691dc099f4c..f2caa9868209 100644
--- a/src/nix-env/profiles.cc
+++ b/src/nix-env/profiles.cc
@@ -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;