blob: dcbd62bbd9b2f634b22691e495908ec2c324f16c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
echo "--- Starting Nix Deep Clean ---"
if [[ $EUID -eq 0 ]]; then
echo "Error: Do not run this script with 'sudo ./clean-nix.sh'."
echo "Run it as your normal user; it will ask for your password when needed."
exit 1
fi
echo "Cleaning system generations..."
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations old
if command -v home-manager &> /dev/null; then
echo "Cleaning Home Manager generations..."
home-manager expire-generations "-0 days"
fi
echo "Cleaning user generations..."
nix-env --delete-generations old
echo "Removing 'result' symlinks in current directory..."
find . -name "result" -type l -delete
echo "Running Garbage Collector..."
sudo nix-collect-garbage -d
nix-collect-garbage -d
echo "Optimising the store (deduplicating files)..."
nix store optimise
echo "--- Clean Up Complete ---"
|