summaryrefslogtreecommitdiff
path: root/pkgs/nixgc.nix
blob: 9e25bd74c18bab504cc975a017e857fedb9b1d90 (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
# this is a shell script that uses the new nix cli to emulate
# nix-collect-garbage
{
  lib,
  writeShellApplication,
  nix,
  fd,
}:
writeShellApplication {
  name = "nixgc";

  runtimeInputs = [nix fd];

  text = ''
    fd . /nix/var/nix/profiles /home/*/.local/state/nix/profiles -d 3 -t symlink -E '*-link' | while read -r profile; do
      nix profile wipe-history --profile "$profile" "$@"
    done
  '';

  meta = with lib; {
    description = "nix-collect-garbage, but with nix profile";
    maintainers = [maintainers.getchoo];
    platforms = platforms.linux;
  };
}