nixos-edit: add clean mode

This commit is contained in:
Daniella / Tove 2024-10-20 10:58:28 +02:00
parent 2886fb86e9
commit dcae161f30

View file

@ -12,6 +12,7 @@ pkgs.writeShellScriptBin "nixos-edit" ''
echo " - test -- edits the OS and switches"
echo " - push -- commits edits from test and pushes them"
echo " - update -- update the system"
echo " - clean -- does housekeeping"
echo " - init -- initialize the system (only run once)"
echo
echo "edit is the default mode."
@ -74,6 +75,15 @@ pkgs.writeShellScriptBin "nixos-edit" ''
exec sudo -iu tudbut nixos-edit $1 || exit 1
fi
if [ "$1" = "clean" ] ; then
echo "> running gc"
sudo nix-collect-garbage --delete-older-than 60d
echo "> hard-linking"
sudo nix-store --optimise
echo "> all done"
exit
fi
[ "$1" = "edit" ] || [ "$1" = "" ] || [ "$1" = "push" ]
PUSH=$?