diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-05-21 12:04:54 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-05-21 12:04:54 +0200 |
commit | a1c1bf3a56fbe7c01dd86fa6b089a2a281f00fc4 (patch) | |
tree | c91c4c2db02d1f2e9bea4c7ec03352f7b41160bc | |
parent | 1529db702b8eaf7b5699f08034ac3b501068d26d (diff) | |
parent | 12a888894bc528fbfa9d4c1ef2dbeb5909550894 (diff) |
Merge branch 'submit/sparse-generation-symlinks' of https://github.com/ctheune/nix
-rw-r--r-- | src/nix-env/profiles.cc | 20 | ||||
-rw-r--r-- | tests/user-envs.sh | 10 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/nix-env/profiles.cc b/src/nix-env/profiles.cc index d93d7fd80..5b7a533df 100644 --- a/src/nix-env/profiles.cc +++ b/src/nix-env/profiles.cc @@ -80,7 +80,25 @@ 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) { + Generation last = gens.back(); + + if (readLink(last.path) == outPath) { + /* 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; + } else { + num = 0; + } /* Create the new generation. Note that addPermRoot() blocks if the garbage collector is running to prevent the stuff we've diff --git a/tests/user-envs.sh b/tests/user-envs.sh index c9eed5a66..5e4fcb7bc 100644 --- a/tests/user-envs.sh +++ b/tests/user-envs.sh @@ -99,6 +99,16 @@ if nix-env -q '*' | grep -q bar; then false; fi nix-env --list-generations test "$(nix-env --list-generations | wc -l)" -eq 7 +# Doing the same operation twice results in the same generation, which triggers +# "lazy" behaviour and does not create a new symlink. + +nix-env -i foo +nix-env -i foo + +# Count generations. +nix-env --list-generations +test "$(nix-env --list-generations | wc -l)" -eq 8 + # Switch to a specified generation. nix-env --switch-generation 7 [ "$(nix-store -q --resolve $profiles/test)" = "$oldGen" ] |