Skip to content
Snippets Groups Projects
Commit a1c1bf3a authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

Merge branch 'submit/sparse-generation-symlinks' of https://github.com/ctheune/nix

parents 1529db70 12a88889
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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" ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment