From f7526febe4e60e3da61664a5fb58ff19a5882ded Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 9 Apr 2003 13:03:00 +0000 Subject: * A garbage collector for installed packages. nix-collect-garbage doesn't actually delete any packages, it just prints their descriptor hashes. So we can do nix info $(nix-collect-garbage) to print out the ids of the packages that would be deleted, and nix delpkg $(nix-collect-garbage) to actually delete them. --- scripts/nix-collect-garbage | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 scripts/nix-collect-garbage (limited to 'scripts/nix-collect-garbage') diff --git a/scripts/nix-collect-garbage b/scripts/nix-collect-garbage new file mode 100755 index 000000000..adaba5b7c --- /dev/null +++ b/scripts/nix-collect-garbage @@ -0,0 +1,22 @@ +#! /usr/bin/perl -w + +my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix +my $linkdir = "$prefix/var/nix/links"; + +my %alive; + +open HASHES, "nix closure \$(cat $linkdir/*.hash) |"; +while () { + chomp; + $alive{$_} = 1; +} +close HASHES; + +open HASHES, "nix listinst |"; +while () { + chomp; + if (!$alive{$_}) { + print "$_\n"; + } +} +close HASHES; -- cgit v1.2.3