bin/hey gc: gc system profile first

Better UX to prompt for root password sooner.
This commit is contained in:
Henrik Lissner 2021-02-26 13:27:17 -05:00
parent 3c8481307b
commit 9d87ac9d49

View file

@ -218,10 +218,6 @@ module Hey
opts "-a", "--all", "GC both the user and system profiles" opts "-a", "--all", "GC both the user and system profiles"
opts "-s", "--system", "Only GC the system profile" opts "-s", "--system", "Only GC the system profile"
lambda do |_args| lambda do |_args|
if @@opts[:all] or not @@opts[:system]
puts "Cleaning up your user profile..."
sh %w{nix-collect-garbage -d}
end
if @@opts[:all] or @@opts[:system] if @@opts[:all] or @@opts[:system]
puts "Cleaning up your system profile..." puts "Cleaning up your system profile..."
sh %w{nix-collect-garbage -d}, sudo: true sh %w{nix-collect-garbage -d}, sudo: true
@ -238,6 +234,10 @@ module Hey
sh %w{nix-env --delete-generations old --profile /nix/var/nix/profiles/system}, sudo: true sh %w{nix-env --delete-generations old --profile /nix/var/nix/profiles/system}, sudo: true
sh %w{/nix/var/nix/profiles/system/bin/switch-to-configuration switch}, sudo: true sh %w{/nix/var/nix/profiles/system/bin/switch-to-configuration switch}, sudo: true
end end
if @@opts[:all] or not @@opts[:system]
puts "Cleaning up your user profile..."
sh %w{nix-collect-garbage -d}
end
end end
end end