bin/hey gc: clean up & delete leftover secrets

This commit is contained in:
Henrik Lissner 2021-01-21 00:32:40 -05:00
parent 3d3497d9e9
commit abf2aeb689

View file

@ -86,14 +86,17 @@ function main {
function _gc { function _gc {
if [[ $EUID == 0 ]]; then if [[ $EUID == 0 ]]; then
echo "Cleaning up your system..." echo "Cleaning up your system..."
_do sudo nix-collect-garbage ${@:--d} _do nix-collect-garbage ${@:--d}
_do nix-store --optimise _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 # 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 # 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 # 2 boot entries at any time). Instead, we properly delete them by
# reloading the current environment. # reloading the current environment.
_do sudo nix-env --delete-generations old --profile /nix/var/nix/profiles/system _do 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/var/nix/profiles/system/bin/switch-to-configuration switch
else else
echo "Cleaning up your user profile..." echo "Cleaning up your user profile..."
_do nix-collect-garbage ${@:--d} _do nix-collect-garbage ${@:--d}