From abf2aeb6892c65fafbfe02ee7358e0fe8596a32d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 21 Jan 2021 00:32:40 -0500 Subject: [PATCH] bin/hey gc: clean up & delete leftover secrets --- bin/hey | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/hey b/bin/hey index 80196691..14e0a35b 100755 --- a/bin/hey +++ b/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}