aboutsummaryrefslogtreecommitdiff
path: root/scripts/gc-nix.sh
blob: 7c22c1d94565d9e4d4d2961eea034343c6fcf56a (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
set -eu

# shellcheck source=/dev/null
. "$DOTFILES/sh/colors.sh"
yellow "Cleaning up the NixOS store\n"

PROFILES="$(mktemp)"
printf "per-user/root/channels\nper-user/andreh/profile\nper-user/andreh/channels\nsystem\n" > "$PROFILES"

while IFS='' read -r p; do
  sudo nix-env --delete-generations old -p "/nix/var/nix/profiles/$p"
done < "$PROFILES"

# Current profile, change when installing with =nix-env -iA nixpkgs.bsdgames=
nix-env --delete-generations old

nix-store --gc
nix-collect-garbage -d