diff options
Diffstat (limited to 'scripts/nix-collect-garbage')
-rwxr-xr-x | scripts/nix-collect-garbage | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/nix-collect-garbage b/scripts/nix-collect-garbage new file mode 100755 index 000000000000..adaba5b7c65b --- /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 (<HASHES>) { + chomp; + $alive{$_} = 1; +} +close HASHES; + +open HASHES, "nix listinst |"; +while (<HASHES>) { + chomp; + if (!$alive{$_}) { + print "$_\n"; + } +} +close HASHES; |