Merge branch 'submit/sparse-generation-symlinks' of https://github.com/ctheune/nix
This commit is contained in:
		
						commit
						a1c1bf3a56
					
				
					 2 changed files with 29 additions and 1 deletions
				
			
		|  | @ -80,7 +80,25 @@ Path createGeneration(Path profile, Path outPath) | ||||||
|        previous ones. */ |        previous ones. */ | ||||||
|     int dummy; |     int dummy; | ||||||
|     Generations gens = findGenerations(profile, 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
 |     /* Create the new generation.  Note that addPermRoot() blocks if
 | ||||||
|        the garbage collector is running to prevent the stuff we've |        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 | nix-env --list-generations | ||||||
| test "$(nix-env --list-generations | wc -l)" -eq 7 | 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. | # Switch to a specified generation. | ||||||
| nix-env --switch-generation 7 | nix-env --switch-generation 7 | ||||||
| [ "$(nix-store -q --resolve $profiles/test)" = "$oldGen" ] | [ "$(nix-store -q --resolve $profiles/test)" = "$oldGen" ] | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue