From dcae161f30115d50a679a8db9b0e7fffad26f020 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sun, 20 Oct 2024 10:58:28 +0200 Subject: [PATCH] nixos-edit: add clean mode --- nixos-edit.script.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos-edit.script.nix b/nixos-edit.script.nix index dbf2ea7..937e338 100644 --- a/nixos-edit.script.nix +++ b/nixos-edit.script.nix @@ -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=$?