bin/hey gc: clean up & delete leftover secrets
This commit is contained in:
		
							parent
							
								
									3d3497d9e9
								
							
						
					
					
						commit
						abf2aeb689
					
				
							
								
								
									
										9
									
								
								bin/hey
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								bin/hey
									
									
									
									
									
								
							|  | @ -86,14 +86,17 @@ function main { | |||
|   function _gc { | ||||
|     if [[ $EUID == 0 ]]; then | ||||
|       echo "Cleaning up your system..." | ||||
|       _do sudo nix-collect-garbage ${@:--d} | ||||
|       _do nix-collect-garbage ${@:--d} | ||||
|       _do nix-store --optimise | ||||
|       # Clear out left-over secrets. The switch-to-configuration call below will | ||||
|       # regenerate them. | ||||
|       [[ -d /run/secrets ]] && _do rm -f /run/secrets/* | ||||
|       # nix-collect-garbage is a Nix tool, not a NixOS tool. It won't delete old | ||||
|       # boot entries until you do a nixos-rebuild (which means we'll always have | ||||
|       # 2 boot entries at any time). Instead, we properly delete them by | ||||
|       # reloading the current environment. | ||||
|       _do sudo nix-env --delete-generations old --profile /nix/var/nix/profiles/system | ||||
|       _do sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch | ||||
|       _do nix-env --delete-generations old --profile /nix/var/nix/profiles/system | ||||
|       _do /nix/var/nix/profiles/system/bin/switch-to-configuration switch | ||||
|     else | ||||
|       echo "Cleaning up your user profile..." | ||||
|       _do nix-collect-garbage ${@:--d} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue